Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(dev): use ruff as linter and formatter #991

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/full-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
os: [Windows, macOS] # exclude Ubuntu as it is available in pr-tests
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
include:
- os: Windows
image: windows-2022
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/latest-deps-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
os: [Ubuntu]
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
include:
- os: Ubuntu
image: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
os: [Ubuntu]
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
include:
- os: Ubuntu
image: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-and-build-wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- name: Set up Python
uses: actions/setup-python@v5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-published-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- name: Set up Python
uses: actions/setup-python@v5
Expand Down
19 changes: 9 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0

hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args: [ "--profile", "black" ]
name: isort (python)
- repo: https://github.com/psf/black
rev: 23.3.0

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.6

hooks:
- id: black
- id: ruff
args: ["--fix"]
- id: ruff-format

- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.4.2
hooks:
Expand All @@ -23,7 +23,6 @@ repos:
args:
- --license-filepath
- LICENSE.md

# Deactivating this for now.
# - repo: https://github.com/pycqa/pylint
# rev: v2.17.0
Expand Down
6 changes: 2 additions & 4 deletions build_notebook_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def _fix_prefix_and_type_in_code_blocks(md_file_path):
updated_block = "\n".join(lines)
content = content.replace(block, updated_block)
block = updated_block
except:
except yaml.YAMLError:
pass

if lines[0] == "```" and "from nemoguardrails" in block:
Expand Down Expand Up @@ -194,9 +194,7 @@ def rename_md_to_readme(start_dir):

# We do some additional post-processing
_remove_code_blocks_with_text(readme_path.absolute(), "# Init:")
_remove_code_blocks_with_text(
readme_path.absolute(), "# Hide from documentation page."
)
_remove_code_blocks_with_text(readme_path.absolute(), "# Hide from documentation page.")

_remove_code_blocks_with_text(
readme_path.absolute(),
Expand Down
10 changes: 3 additions & 7 deletions docs/colang-2/examples/test_csl.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
import sys

import pytest
from utils import compare_interaction_with_test_script

pathlib.Path(__file__).parent.parent.parent.resolve()
sys.path.append(str(pathlib.Path(__file__).parent.parent.parent.parent.resolve()))
print(sys.path)

from utils import compare_interaction_with_test_script

########################################################################################################################
# CORE
Expand Down Expand Up @@ -637,9 +637,7 @@ async def test_repeating_timer():
# USAGE_END: test_repeating_timer
"""

await compare_interaction_with_test_script(
test_script, colang_code, wait_time_s=2.0
)
await compare_interaction_with_test_script(test_script, colang_code, wait_time_s=2.0)


@pytest.mark.asyncio
Expand Down Expand Up @@ -809,9 +807,7 @@ async def test_polling_llm_request_response():
# USAGE_END: test_polling_llm_request_response
"""

await compare_interaction_with_test_script(
test_script, colang_code, llm_responses=['"nine"']
)
await compare_interaction_with_test_script(test_script, colang_code, llm_responses=['"nine"'])


@pytest.mark.asyncio
Expand Down
6 changes: 3 additions & 3 deletions docs/colang-2/examples/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ async def compare_interaction_with_test_script(
)
clean_test_script = cleanup(test_script)
clean_result = cleanup(result)
assert (
clean_test_script == clean_result
), f"\n----\n{clean_result}\n----\n\ndoes not match test script\n\n----\n{clean_test_script}\n----"
assert clean_test_script == clean_result, (
f"\n----\n{clean_result}\n----\n\ndoes not match test script\n\n----\n{clean_test_script}\n----"
)
Loading