Skip to content

Commit 3d8a651

Browse files
Use ruff for linting and formatting (#99)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/psf/black: 23.12.1 → 24.1.1](psf/black@23.12.1...24.1.1) - [github.com/PyCQA/bandit: 1.7.6 → 1.7.7](PyCQA/bandit@1.7.6...1.7.7) - [github.com/crate-ci/typos: v1.17.1 → v1.17.2](crate-ci/typos@v1.17.1...v1.17.2) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Use ruff --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Felix Uellendall <[email protected]>
1 parent 4551604 commit 3d8a651

File tree

5 files changed

+30
-64
lines changed

5 files changed

+30
-64
lines changed

.bandit

-4
This file was deleted.

.pre-commit-config.yaml

+9-57
Original file line numberDiff line numberDiff line change
@@ -24,66 +24,18 @@ repos:
2424
- id: mypy
2525
additional_dependencies:
2626
- types-toml
27-
- repo: https://github.com/pre-commit/pygrep-hooks
28-
rev: v1.10.0
29-
hooks:
30-
- id: python-check-blanket-noqa
31-
- id: python-check-blanket-type-ignore
32-
- id: python-check-mock-methods
33-
- id: python-no-eval
34-
- id: python-no-log-warn
35-
- id: python-use-type-annotations
36-
- repo: https://github.com/asottile/add-trailing-comma
37-
rev: v3.1.0
38-
hooks:
39-
- id: add-trailing-comma
40-
- repo: https://github.com/asottile/pyupgrade
41-
rev: v3.15.0
42-
hooks:
43-
- id: pyupgrade
44-
- repo: https://github.com/asottile/yesqa
45-
rev: v1.5.0
46-
hooks:
47-
- id: yesqa
48-
- repo: https://github.com/psf/black
49-
rev: 23.12.1
50-
hooks:
51-
- id: black
52-
- repo: https://github.com/PyCQA/flake8
53-
rev: 7.0.0
54-
hooks:
55-
- id: flake8
56-
args: ["--max-line-length", "88", "--extend-ignore", "E501"]
57-
additional_dependencies:
58-
- flake8-bugbear
59-
- flake8-builtins
60-
- repo: https://github.com/PyCQA/bandit
61-
rev: 1.7.6
62-
hooks:
63-
- id: bandit
64-
args: ["-c", ".bandit"]
65-
- repo: https://github.com/PyCQA/pydocstyle
66-
rev: 6.3.0
67-
hooks:
68-
- id: pydocstyle
69-
args: ["--convention", "pep257", "--add-ignore", "D100,D102"]
70-
additional_dependencies:
71-
- toml
72-
exclude: airflint/__main__.py|tests/
73-
- repo: https://github.com/pycqa/isort
74-
rev: 5.13.2
75-
hooks:
76-
- id: isort
77-
args: ["--profile", "black"]
27+
- repo: https://github.com/astral-sh/ruff-pre-commit
28+
rev: v0.1.15
29+
hooks:
30+
- id: ruff
31+
args:
32+
- --fix
33+
- --unsafe-fixes
34+
- id: ruff-format
7835
- repo: https://github.com/crate-ci/typos
79-
rev: v1.17.1
36+
rev: v1.17.2
8037
hooks:
8138
- id: typos
82-
- repo: https://github.com/pycqa/autoflake
83-
rev: v2.2.1
84-
hooks:
85-
- id: autoflake
86-
args: ["--remove-all-unused-imports", "--in-place"]
8739
- repo: local
8840
hooks:
8941
- id: pytest

airflint/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Top-level package for airflint."""
2+
23
from importlib.metadata import version
34
from os import getcwd
45
from os.path import dirname, join, realpath

airflint/rules/use_jinja_variable_get.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,16 @@ def _lookup_template_fields(self, keyword: ast.keyword) -> None:
5656
and scope.can_reach(self.context["scope"].resolve(node))
5757
)
5858
except StopIteration:
59-
raise AssertionError("Could not find import definition. Skipping..")
59+
raise AssertionError(
60+
"Could not find import definition. Skipping.."
61+
) from None
6062
assert (module_name := import_node.module)
6163

6264
# Try to import the module into python.
6365
try:
6466
_module = import_module(module_name)
65-
except ImportError:
66-
raise AssertionError("Could not import module. Skipping..")
67+
except ImportError as e:
68+
raise AssertionError("Could not import module. Skipping..") from e
6769
assert (file_path := _module.__file__)
6870

6971
# Parse the ast to check if the keyword is in template_fields.

pyproject.toml

+15
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,18 @@ build-backend = "poetry.core.masonry.api"
2424

2525
[tool.coverage.run]
2626
omit = ["airflint/__main__.py"]
27+
28+
[tool.ruff]
29+
target-version = "py39"
30+
31+
[tool.ruff.lint]
32+
select = ["E4", "E7", "E9", "F", "B", "S", "UP", "PGH", "D", "I", "A"]
33+
ignore = ["D100", "D102"]
34+
35+
[tool.ruff.per-file-ignores]
36+
"tests/*" = ["S101", "D"]
37+
"airflint/rules/*.py" = ["S101"]
38+
"airflint/__main__.py" = ["D"]
39+
40+
[tool.ruff.pydocstyle]
41+
convention = "pep257"

0 commit comments

Comments
 (0)