Skip to content

Commit a021cc8

Browse files
authored
Use ruff (#359)
* Add config Signed-off-by: Bernát Gábor <[email protected]> * Add config Signed-off-by: Bernát Gábor <[email protected]> * Run formatter Signed-off-by: Bernát Gábor <[email protected]> * Fix type annotations Signed-off-by: Bernát Gábor <[email protected]> * Finalize fixes Signed-off-by: Bernát Gábor <[email protected]> --------- Signed-off-by: Bernát Gábor <[email protected]>
1 parent d7613ad commit a021cc8

22 files changed

+529
-460
lines changed

.pre-commit-config.yaml

+9-52
Original file line numberDiff line numberDiff line change
@@ -2,76 +2,33 @@ repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
33
rev: v4.4.0
44
hooks:
5-
- id: check-ast
6-
- id: check-builtin-literals
7-
- id: check-docstring-first
8-
- id: check-merge-conflict
9-
- id: check-yaml
10-
- id: check-toml
11-
- id: debug-statements
125
- id: end-of-file-fixer
136
- id: trailing-whitespace
14-
- repo: https://github.com/asottile/pyupgrade
15-
rev: v3.3.1
7+
- repo: https://github.com/astral-sh/ruff-pre-commit
8+
rev: "v0.0.272"
169
hooks:
17-
- id: pyupgrade
18-
args: ["--py38-plus"]
19-
exclude: "^(tests/roots/test-dummy/dummy_module.py)$"
20-
- id: pyupgrade
21-
files: "^(tests/roots/test-dummy/dummy_module.py)$"
22-
args: ["--py36-plus"]
23-
- repo: https://github.com/PyCQA/isort
24-
rev: 5.12.0
25-
hooks:
26-
- id: isort
10+
- id: ruff
11+
args: [--fix, --exit-non-zero-on-fix]
2712
- repo: https://github.com/psf/black
2813
rev: 23.3.0
2914
hooks:
3015
- id: black
31-
args: [--safe]
32-
- repo: https://github.com/asottile/blacken-docs
33-
rev: 1.13.0
34-
hooks:
35-
- id: blacken-docs
36-
additional_dependencies: [black==23.3]
37-
- repo: https://github.com/pre-commit/pygrep-hooks
38-
rev: v1.10.0
39-
hooks:
40-
- id: rst-backticks
4116
- repo: https://github.com/tox-dev/tox-ini-fmt
4217
rev: "1.3.0"
4318
hooks:
4419
- id: tox-ini-fmt
4520
args: ["-p", "fix"]
46-
- repo: https://github.com/PyCQA/flake8
47-
rev: 6.0.0
21+
- repo: https://github.com/tox-dev/pyproject-fmt
22+
rev: "0.11.2"
4823
hooks:
49-
- id: flake8
50-
additional_dependencies:
51-
- flake8-bugbear==23.3.23
52-
- flake8-comprehensions==3.12
53-
- flake8-pytest-style==1.7.2
54-
- flake8-spellcheck==0.28
55-
- flake8-unused-arguments==0.0.13
56-
- flake8-noqa==1.3.1
57-
- pep8-naming==0.13.3
24+
- id: pyproject-fmt
25+
additional_dependencies: ["tox>=4.6"]
5826
- repo: https://github.com/pre-commit/mirrors-prettier
59-
rev: "v2.7.1"
27+
rev: "v3.0.0-alpha.9-for-vscode"
6028
hooks:
6129
- id: prettier
62-
additional_dependencies:
63-
64-
- "@prettier/[email protected]"
6530
args: ["--print-width=120", "--prose-wrap=always"]
66-
- repo: https://github.com/igorshubovych/markdownlint-cli
67-
rev: v0.33.0
68-
hooks:
69-
- id: markdownlint
7031
- repo: meta
7132
hooks:
7233
- id: check-hooks-apply
7334
- id: check-useless-excludes
74-
- repo: https://github.com/tox-dev/pyproject-fmt
75-
rev: "0.9.2"
76-
hooks:
77-
- id: pyproject-fmt

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@
273273

274274
## 1.2.1
275275

276-
- Fixed `` ValueError` when ``getargspec()\`\` encounters a built-in function
276+
- Fixed ``ValueError` when``getargspec()\`\` encounters a built-in function
277277
- Fixed `AttributeError` when `Any` is combined with another type in a `Union` (thanks Davis Kirkendall)
278278

279279
## 1.2.0

pyproject.toml

+34-17
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
build-backend = "hatchling.build"
33
requires = [
44
"hatch-vcs>=0.3",
5-
"hatchling>=1.14",
5+
"hatchling>=1.17.1",
66
]
77

88
[project]
@@ -26,30 +26,34 @@ classifiers = [
2626
"Intended Audience :: Developers",
2727
"License :: OSI Approved :: MIT License",
2828
"Programming Language :: Python",
29-
"Programming Language :: Python :: 3",
3029
"Programming Language :: Python :: 3 :: Only",
30+
"Programming Language :: Python :: 3.8",
31+
"Programming Language :: Python :: 3.9",
32+
"Programming Language :: Python :: 3.10",
33+
"Programming Language :: Python :: 3.11",
34+
"Programming Language :: Python :: 3.12",
3135
"Topic :: Documentation :: Sphinx",
3236
]
3337
dynamic = [
3438
"version",
3539
]
3640
dependencies = [
37-
"Sphinx>=6.1.3",
41+
"Sphinx>=7.0.1",
3842
]
3943
optional-dependencies.docs = [
40-
"furo>=2023.3.27",
41-
"sphinx>=6.1.3",
44+
"furo>=2023.5.20",
45+
"sphinx>=7.0.1",
4246
"sphinx-autodoc-typehints>=1.23.4",
4347
]
4448
optional-dependencies.testing = [
4549
"covdefaults>=2.3",
46-
"coverage>=7.2.3",
50+
"coverage>=7.2.7",
4751
"diff-cover>=7.5",
4852
"nptyping>=2.5",
4953
"pytest>=7.3.1",
50-
"pytest-cov>=4",
54+
"pytest-cov>=4.1",
5155
"sphobjinv>=2.3.1",
52-
"typing-extensions>=4.5",
56+
"typing-extensions>=4.6.3",
5357
]
5458
optional-dependencies.type-comment = [
5559
'typed-ast>=1.5.4; python_version < "3.8"',
@@ -66,11 +70,6 @@ version.source = "vcs"
6670
[tool.black]
6771
line-length = 120
6872

69-
[tool.isort]
70-
line_length = 120
71-
profile = "black"
72-
known_first_party = ["sphinx_autodoc_typehints", "tests"]
73-
7473
[tool.pytest.ini_options]
7574
testpaths = ["tests"]
7675

@@ -94,8 +93,26 @@ run.plugins = ["covdefaults"]
9493
python_version = "3.10"
9594
strict = true
9695
exclude = "^(.*/roots/.*)|(tests/test_integration.py)$"
96+
overrides = [{ module = ["sphobjinv.*"], ignore_missing_imports = true }]
9797

98-
99-
[[tool.mypy.overrides]]
100-
module = ["sphobjinv"]
101-
ignore_missing_imports = true
98+
[tool.ruff]
99+
select = ["ALL"]
100+
line-length = 120
101+
target-version = "py37"
102+
isort = {known-first-party = ["tox", "tests"], required-imports = ["from __future__ import annotations"]}
103+
ignore = [
104+
"ANN101", # no typoe annotation for self
105+
"ANN401", # allow Any as type annotation
106+
"D203", # `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible
107+
"D212", # `multi-line-summary-first-line` (D212) and `multi-line-summary-second-line` (D213) are incompatible
108+
"S104", # Possible binding to all interface
109+
]
110+
[tool.ruff.per-file-ignores]
111+
"tests/**/*.py" = [
112+
"S101", # asserts allowed in tests...
113+
"FBT", # don"t care about booleans as positional arguments in tests
114+
"INP001", # no implicit namespace
115+
"D", # don"t care about documentation in tests
116+
"S603", # `subprocess` call: check for execution of untrusted input
117+
"PLR2004", # Magic value used in comparison, consider replacing with a constant variable
118+
]

0 commit comments

Comments
 (0)