Skip to content

Update linters in Ruff #894

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

Closed
wants to merge 18 commits into from
14 changes: 8 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ jobs:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip uv
python -m uv pip install ruff==0.5.2
python -m pip install --upgrade pip
python -m pip install uv
python -m uv pip install ruff==0.6.3
# Update output format to enable automatic inline annotations.
- name: Run Ruff Linter
run: ruff check --output-format=github
- name: Run Ruff Formatter
run: ruff format --check
# - name: Run Ruff Formatter
# run: ruff format --check

test:
runs-on: ubuntu-latest
Expand All @@ -38,10 +39,11 @@ jobs:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip uv
python -m pip install --upgrade pip
python -m pip install uv
python -m uv pip install torch==2.3.1+cpu torchvision==0.18.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
make install_dev
- name: Test with pytest
Expand Down
72 changes: 72 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".ipynb_checkpoints",
".mypy_cache",
".nox",
".pants.d",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
]

# Same as Black.
line-length = 120
indent-width = 4

# Assume Python 3.11
target-version = "py311"

[lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
select = [
# "E", # pycodestyle
# "F", # pyglake
# "I", # Isort
"PERF", # Perlint
# "PL", # Pylint
# "RUF", # Ruff
# "S", # Bandit
# "SIM", # Simplify
# "UP", # Upgrade
# "W", # Warning
]
ignore = []

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[format]
# Like Black, use double quotes for strings.
quote-style = "double"

# Like Black, indent with spaces, rather than tabs.
indent-style = "space"

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
REQUIRED = []

# What packages are optional?
EXTRAS = {"test": ["pytest", "mock", "ruff==0.5.2"]}
EXTRAS = {"test": ["pytest", "mock", "ruff==0.6.3"]}

# Import the README and use it as the long-description.
# Note: this will only work if 'README.md' is present in your MANIFEST.in file!
Expand Down
Loading