Skip to content

Commit

Permalink
lint: replace flake8 with ruff check
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda committed Mar 11, 2024
1 parent 12c139c commit 23f616b
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 37 deletions.
26 changes: 0 additions & 26 deletions .flake8

This file was deleted.

13 changes: 6 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ repos:
name: black (format)
exclude: ^git/ext/

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.0
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear==23.9.16
- flake8-comprehensions==3.14.0
- flake8-typing-imports==1.14.0
#- id: ruff-format # todo: eventually replace Black with Ruff for consistency
# args: ["--preview"]
- id: ruff
args: ["--fix"]
exclude: ^doc|^git/ext/

- repo: https://github.com/shellcheck-py/shellcheck-py
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ The same linting, and running tests on all the different supported Python versio
Specific tools:

- Configurations for `mypy`, `pytest`, `coverage.py`, and `black` are in `./pyproject.toml`.
- Configuration for `flake8` is in the `./.flake8` file.
- Configuration for `ruff` is in the `pyproject.toml` file.

Orchestration tools:

Expand Down
38 changes: 37 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ warn_unreachable = true
show_error_codes = true
implicit_reexport = true
# strict = true

# TODO: Remove when 'gitdb' is fully annotated.
exclude = ["^git/ext/gitdb"]
[[tool.mypy.overrides]]
Expand All @@ -47,3 +46,40 @@ omit = ["*/git/ext/*"]
line-length = 120
target-version = ["py37"]
extend-exclude = "git/ext/gitdb"

[tool.ruff]
target-version = "py37"
line-length = 120
# Exclude a variety of commonly ignored directories.
exclude = [
"git/ext/",
"doc",
"build",
"dist",
]
# Enable Pyflakes `E` and `F` codes by default.
lint.select = [
"E",
"W", # see: https://pypi.org/project/pycodestyle
"F", # see: https://pypi.org/project/pyflakes
# "I", #see: https://pypi.org/project/isort/
# "S", # see: https://pypi.org/project/flake8-bandit
# "UP", # see: https://docs.astral.sh/ruff/rules/#pyupgrade-up
]
lint.extend-select = [
"A", # see: https://pypi.org/project/flake8-builtins
"B", # see: https://pypi.org/project/flake8-bugbear
"C4", # see: https://pypi.org/project/flake8-comprehensions
"TCH004", # see: https://docs.astral.sh/ruff/rules/runtime-import-in-type-checking-block/
]
lint.ignore = [
"E203", "W503"
]
lint.ignore-init-module-imports = true
lint.unfixable = ["F401"]

#[tool.ruff.lint.per-file-ignores]
#"setup.py" = ["ANN202", "ANN401"]
#"docs/source/conf.py" = ["A001", "D103"]
#"src/**" = ["ANN401"]
#"tests/**" = ["S101", "ANN001", "ANN201", "ANN202", "ANN401"]
2 changes: 0 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@

# libraries for additional local testing/linting - to be added to test-requirements.txt when all pass

flake8-type-checking;python_version>="3.8" # checks for TYPE_CHECKING only imports

pytest-icdiff
# pytest-profiling

0 comments on commit 23f616b

Please sign in to comment.