Skip to content

Commit

Permalink
Use ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
wsanchez committed Nov 25, 2024
1 parent a031da5 commit 29a4df9
Show file tree
Hide file tree
Showing 89 changed files with 456 additions and 1,079 deletions.
78 changes: 0 additions & 78 deletions .flake8

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
uses: astral-sh/setup-uv@v4

- name: Set up Tox environment
run: uvx --with=tox-uv tox run -e lint --notest
run: uvx --with=tox-uv tox run -e mypy --notest

- name: Run Mypy
run: uvx --with=tox-uv tox run -e mypy
Expand Down Expand Up @@ -129,7 +129,7 @@ jobs:
uses: astral-sh/setup-uv@v4

- name: Set up Tox environment
run: uvx --with=tox-uv tox run -e lint --notest
run: uvx --with=tox-uv tox run -e packaging --notest

- name: Check packaging
run: uvx --with=tox-uv tox run -e packaging
Expand Down Expand Up @@ -223,7 +223,7 @@ jobs:
uses: astral-sh/setup-uv@v4

- name: Set up Tox environment
run: uvx --with=tox-uv tox run -e lint --notest
run: uvx --with=tox-uv tox run -e "${TOX_ENV}" --notest

- name: Run unit tests
id: test
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ __pycache__/
/.docker_environment
/.docker/*
/.hypothesis/
/.ruff_cache
/.tox/
/.venv/
/build/
Expand Down
13 changes: 0 additions & 13 deletions .isort.cfg

This file was deleted.

72 changes: 5 additions & 67 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,62 +4,12 @@ ci:

repos:

- repo: https://github.com/asottile/pyupgrade
rev: "v3.19.0"
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.8.0
hooks:
- id: pyupgrade
args: ["--py313-plus"]

- repo: https://github.com/psf/black
rev: "24.10.0"
hooks:
- id: black
args: ["--target-version", "py313"]

- repo: https://github.com/PyCQA/autoflake
rev: "v2.3.1"
hooks:
- id: autoflake
args:
- --in-place
- --remove-all-unused-imports
- --expand-star-imports
- --remove-duplicate-keys
- --remove-unused-variables

- repo: https://github.com/PyCQA/flake8
rev: "7.1.1"
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear==24.8.19
- flake8-docstrings==1.7.0
- flake8-mutable==1.2.0
- flake8-pep3101==2.1.0
- pep8-naming==0.14.1
- pycodestyle==2.12.1
- pydocstyle==6.3.0
- pyflakes==3.2.0

- repo: https://github.com/asottile/yesqa
rev: "v1.5.0"
hooks:
- id: yesqa
additional_dependencies:
- flake8-bugbear==24.8.19
- flake8-docstrings==1.7.0
- flake8-mutable==1.2.0
- flake8-pep3101==2.1.0
- pep8-naming==0.14.1
- pycodestyle==2.12.1
- pydocstyle==6.3.0
- pyflakes==3.2.0

- repo: https://github.com/PyCQA/isort
rev: "5.13.2"
hooks:
- id: isort
args: ["--filter-files"]
- id: ruff
- id: ruff-format

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v5.0.0"
Expand Down Expand Up @@ -92,18 +42,6 @@ repos:
args: ["--branch", "master"]
- id: trailing-whitespace

- repo: https://github.com/pre-commit/pygrep-hooks
rev: "v1.10.0"
hooks:
- id: python-check-blanket-noqa
# - id: python-check-blanket-type-ignore
- id: python-no-eval
- id: python-use-type-annotations
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
- id: text-unicode-replacement-char

- repo: https://github.com/mgedmin/check-manifest
rev: "0.50"
hooks:
Expand Down
2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
include .coveragerc
include .docker/sample.env
include .dockerignore
include .flake8
include .isort.cfg
include .pre-commit-config.yaml
include .python-version
include bin/.common.sh
Expand Down
2 changes: 0 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,8 @@ Pull requests in GitHub will run all tests on Travis CI, and all are required to

.. ------------------------------------------------------------------------- ..
.. _Flake8: http://flake8.pycqa.org/
.. _Klein: https://klein.readthedocs.io/
.. _Mypy: http://mypy.readthedocs.io/
.. _pipx: https://pipx.pypa.io/stable/
.. _pre-commit: https://pre-commit.com/
.. _tox-uv: https://github.com/tox-dev/tox-uv
.. _Tox: http://tox.readthedocs.io/
Expand Down
2 changes: 2 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Configuration file for the Sphinx documentation builder.
"""

# ruff: noqa: INP001

# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
Expand Down
137 changes: 131 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,139 @@ build-backend = "setuptools.build_meta"


##
# Black
# Ruff
##

[tool.black]

line-length = 80
target-version = ["py313"]

[tool.ruff.format]

# skip-magic-trailing-comma = true


[tool.ruff.lint]

select = ["ALL"]
ignore = [
"B008", # Do not perform function call in argument defaults
"COM812", # Trailing comma missing
"D105", # Missing docstring in magic method
"D200", # One-line docstring should fit on one line
"D202", # No blank lines allowed after function docstring
"D203", # Use a blank line to separate the docstring from the class definition
"D205", # 1 blank line required between summary line and description
"D212", # Multi-line docstring summary should start at the first line
"D213", # Multi-line docstring summary should start at the second line
"D400", # First line should end with a period
"D401", # First line of docstring should be in imperative mood
"D415", # First line should end with a period, question mark, or exclamation point
"N802", # Function name should be lowercase
"N803", # Argument name should be lowercase
"N806", # Variable in function should be lowercase
"N812", # Lowercase imported as non-lowercase
"N815", # Variable in class scope should not be mixedCase
"N816", # Variable in global scope should not be mixedCase
"PT009", # Use a regular `assert` instead of unittest-style

# Reconsider
"TID252", # Prefer absolute imports over relative imports from parent modules

# TODO
"A001", # Variable `min` is shadowing a Python builtin
"A002", # Function argument is shadowing a Python builtin
"A004", # Import is shadowing a Python builtin
"ANN001", # Missing type annotation for function argument
"ANN002", # Missing type annotation for `*args`
"ANN003", # Missing type annotation for `**kwargs`
"ANN202", # Missing return type annotation for private function
"ANN204", # Missing return type annotation for special method
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed
"ARG001", # Unused function argument
"ARG002", # Unused method argument
"ARG003", # Unused class method argument
"ARG004", # Unused static method argument
"ARG005", # Unused lambda argument
"B024", # `Address` is an abstract base class, but it has no abstract methods or properties
"BLE001", # Do not catch blind exception
"C408", # Unnecessary `dict` call (rewrite as a literal)
"C413", # Unnecessary `reversed` call around `sorted()`
"C901", # is too complex
"DTZ001", # `datetime.datetime()` called without a `tzinfo` argument
"DTZ005", # `datetime.datetime.now()` called without a `tz` argument
"EM101", # Exception must not use a string literal, assign to variable first
"EM102", # Exception must not use an f-string literal, assign to variable first
"EM103", # Exception must not use a `.format()` string directly, assign to variable first
"ERA001", # Found commented-out code
"FBT001", # Boolean-typed positional argument in function definition
"FBT002", # Boolean default positional argument in function definition
"FBT003", # Boolean positional value in function call
"FIX001", # Line contains FIXME, consider resolving the issue
"I001", # Import block is un-sorted or un-formatted
"ISC001", # Implicitly concatenated string literals on one line
"PERF102", # When using only the keys of a dict use the `keys()` method
"PERF401", # Use a list comprehension to create a transformed list
"PGH003", # Use specific rule codes when ignoring type issues
"PIE796", # Enum contains duplicate value: `str`
"PLE0605", # Invalid format for `__all__`, must be `tuple` or `list`
"PLR0911", # Too many return statements
"PLR0912", # Too many branches
"PLR0913", # Too many arguments in function definition
"PLR0915", # Too many statements
"PLR1704", # Redefining argument with the local name
"PLR1711", # Useless `return` statement at end of function
"PLR1714", # Consider merging multiple comparisons
"PLR2004", # Magic value used in comparison, consider replacing with a constant variable
"PLR5501", # Use `elif` instead of `else` then `if`, to reduce indentation
"PLW0120", # `else` clause on loop without a `break` statement; remove the `else` and dedent its contents
"PLW2901", # `for` loop variable overwritten by assignment target
"PT019", # Fixture without value is injected as parameter, use `@pytest.mark.usefixtures` instead
"PT027", # Use `pytest.raises` instead of unittest-style
"PTH100", # `os.path.abspath()` should be replaced by `Path.resolve()`
"PTH109", # `os.getcwd()` should be replaced by `Path.cwd()`
"PTH110", # `os.path.exists()` should be replaced by `Path.exists()`
"PTH118", # `os.path.join()` should be replaced by `Path` with `/` operator
"PTH119", # `os.path.basename()` should be replaced by `Path.name`
"PTH123", # `open()` should be replaced by `Path.open()`
"PTH202", # `os.path.getsize` should be replaced by `Path.stat().st_size`
"PYI032", # Prefer `object` to `Any` for the second parameter to `__ne__`
"PYI036", # The second argument in `__exit__` should be annotated with `object` or `BaseException | None`
"RET501", # Do not explicitly `return None` in function if it is the only possible return value
"RET504", # Unnecessary assignment before `return` statement
"RET505", # Unnecessary `else` after `return` statement
"RET506", # Unnecessary `else` after `raise` statement
"RET507", # Unnecessary `else` after `continue` statement
"RSE102", # Unnecessary parentheses on raised exception
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"RUF022", # `__all__` is not sorted
"RUF100", # Unused `noqa` directive
"S101", # Use of `assert` detected
"S105", # Possible hardcoded password assigned to
"S106", # Possible hardcoded password assigned to argument
"S324", # Probable use of insecure hash functions in `hashlib`
"S608", # Possible SQL injection vector through string-based query construction
"SIM102", # Use a single `if` statement instead of nested `if` statements
"SIM105", # Use `contextlib.suppress(NoSectionError, NoOptionError)` instead of `try`-`except`-`pass`
"SIM108", # Use ternary operator
"SIM114", # Combine `if` branches using logical `or` operator
"SIM115", # Use a context manager for opening files
"SIM118", # Use `key in dict` instead of `key in dict.keys()`
"SLF001", # Private member accessed
"T201", # `print` found
"T203", # `pprint` found
"TC001", # Move application import into a type-checking block
"TC003", # Move standard library import into a type-checking block
"TD001", # Invalid TODO tag: `FIXME`
"TD002", # Missing author in TODO
"TD003", # Missing issue link on the line following this TODO
"TRY003", # Avoid specifying long messages outside the exception class
"TRY301", # Abstract `raise` to an inner function
"TRY400", # Use `logging.exception` instead of `logging.error`
"UP006", # Use `collections.deque` instead of `Deque` for type annotation
"UP007", # Use `X | Y` for type annotations
"UP017", # Use `datetime.UTC` alias
"UP031", # Use format specifiers instead of percent format
"UP032", # Use f-string instead of `format` call
"UP035", # `typing.Deque` is deprecated, use `collections.deque` instead
"UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)`
]

##
# Setuptools
Expand Down
Loading

0 comments on commit 29a4df9

Please sign in to comment.