Skip to content

Commit d14728a

Browse files
authored
Add ruff (#81)
Signed-off-by: Bernát Gábor <[email protected]>
1 parent 54e96b0 commit d14728a

21 files changed

+228
-250
lines changed

.github/workflows/check.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ jobs:
2525
- "3.8"
2626
- "3.7"
2727
os:
28-
- ubuntu-22.04
29-
- windows-2022
30-
- macos-12
28+
- ubuntu-latest
29+
- windows-latest
30+
- macos-latest
3131
steps:
3232
- name: Setup python for tox
3333
uses: actions/setup-python@v4
@@ -71,10 +71,10 @@ jobs:
7171
- docs
7272
- pkg_meta
7373
os:
74-
- ubuntu-22.04
75-
- windows-2022
74+
- ubuntu-latest
75+
- windows-latest
7676
exclude:
77-
- { os: windows-2022, tox_env: pkg_meta }
77+
- { os: windows-latest, tox_env: pkg_meta }
7878
steps:
7979
- uses: actions/checkout@v3
8080
with:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55

66
jobs:
77
release:
8-
runs-on: ubuntu-22.04
8+
runs-on: ubuntu-latest
99
environment:
1010
name: release
1111
url: https://pypi.org/p/pyproject-api

.markdownlint.yaml

Lines changed: 0 additions & 12 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 18 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,74 +2,43 @@ 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.2
7+
- repo: https://github.com/astral-sh/ruff-pre-commit
8+
rev: "v0.0.272"
169
hooks:
17-
- id: pyupgrade
18-
args: ["--py37-plus"]
19-
exclude: "^(src/pyproject_api/_backend.py|tests/demo_pkg_inline/build.py)$"
20-
- repo: https://github.com/PyCQA/isort
21-
rev: 5.12.0
22-
hooks:
23-
- id: isort
10+
- id: ruff
11+
exclude: src/pyproject_api/_backend.py
12+
args: [--fix, --exit-non-zero-on-fix]
2413
- repo: https://github.com/psf/black
2514
rev: 23.3.0
2615
hooks:
2716
- id: black
28-
args: [--safe]
29-
- repo: https://github.com/asottile/blacken-docs
30-
rev: 1.13.0
31-
hooks:
32-
- id: blacken-docs
33-
additional_dependencies: [black==23.3]
34-
- repo: https://github.com/pre-commit/pygrep-hooks
35-
rev: v1.10.0
36-
hooks:
37-
- id: rst-backticks
3817
- repo: https://github.com/tox-dev/tox-ini-fmt
3918
rev: "1.3.0"
4019
hooks:
4120
- id: tox-ini-fmt
4221
args: ["-p", "fix"]
43-
- repo: https://github.com/PyCQA/flake8
44-
rev: 6.0.0
22+
- repo: https://github.com/tox-dev/pyproject-fmt
23+
rev: "0.11.2"
4524
hooks:
46-
- id: flake8
47-
additional_dependencies:
48-
- flake8-bugbear==23.3.23
49-
- flake8-comprehensions==3.12
50-
- flake8-pytest-style==1.7.2
51-
- flake8-spellcheck==0.28
52-
- flake8-unused-arguments==0.0.13
53-
- flake8-noqa==1.3.1
54-
- pep8-naming==0.13.3
55-
- flake8-pyproject==1.2.3
25+
- id: pyproject-fmt
26+
additional_dependencies: ["tox>=4.6"]
5627
- repo: https://github.com/pre-commit/mirrors-prettier
57-
rev: "v2.7.1"
28+
rev: "v3.0.0-alpha.9-for-vscode"
5829
hooks:
5930
- id: prettier
60-
additional_dependencies:
61-
62-
- "@prettier/[email protected]"
6331
args: ["--print-width=120", "--prose-wrap=always"]
64-
- repo: https://github.com/igorshubovych/markdownlint-cli
65-
rev: v0.33.0
32+
- repo: https://github.com/asottile/blacken-docs
33+
rev: 1.14.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
6639
hooks:
67-
- id: markdownlint
40+
- id: rst-backticks
6841
- repo: meta
6942
hooks:
7043
- id: check-hooks-apply
7144
- id: check-useless-excludes
72-
- repo: https://github.com/tox-dev/pyproject-fmt
73-
rev: "0.10.0"
74-
hooks:
75-
- id: pyproject-fmt

docs/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
# noqa: D100
12
from __future__ import annotations
23

34
from pyproject_api import __version__
45

56
project = name = "pyproject_api"
67
company = "tox-dev"
7-
copyright = f"{company}"
8+
copyright = f"{company}" # noqa: A001
89
version, release = __version__, __version__.split("+")[0]
910

1011
extensions = [

pyproject.toml

Lines changed: 35 additions & 19 deletions
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.1",
5+
"hatchling>=1.17.1",
66
]
77

88
[project]
@@ -28,6 +28,13 @@ classifiers = [
2828
"Operating System :: MacOS :: MacOS X",
2929
"Operating System :: Microsoft :: Windows",
3030
"Operating System :: POSIX",
31+
"Programming Language :: Python :: 3 :: Only",
32+
"Programming Language :: Python :: 3.7",
33+
"Programming Language :: Python :: 3.8",
34+
"Programming Language :: Python :: 3.9",
35+
"Programming Language :: Python :: 3.10",
36+
"Programming Language :: Python :: 3.11",
37+
"Programming Language :: Python :: 3.12",
3138
"Topic :: Software Development :: Libraries",
3239
"Topic :: Software Development :: Testing",
3340
"Topic :: Utilities",
@@ -40,17 +47,17 @@ dependencies = [
4047
'tomli>=2.0.1; python_version < "3.11"',
4148
]
4249
optional-dependencies.docs = [
43-
"furo>=2023.3.27",
44-
"sphinx>=6.2.1",
50+
"furo>=2023.5.20",
51+
"sphinx>=7.0.1",
4552
"sphinx-autodoc-typehints!=1.23.4,>=1.23",
4653
]
4754
optional-dependencies.testing = [
4855
"covdefaults>=2.3",
4956
'importlib-metadata>=6.6; python_version < "3.8"',
5057
"pytest>=7.3.1",
51-
"pytest-cov>=4",
58+
"pytest-cov>=4.1",
5259
"pytest-mock>=3.10",
53-
"setuptools>=67.7.2",
60+
"setuptools>=67.8",
5461
"wheel>=0.40",
5562
]
5663
urls.Homepage = "http://pyproject_api.readthedocs.org"
@@ -64,18 +71,6 @@ version.source = "vcs"
6471
[tool.black]
6572
line-length = 120
6673

67-
[tool.isort]
68-
known_first_party = ["pyproject_api"]
69-
profile = "black"
70-
line_length = 120
71-
72-
[tool.flake8]
73-
max-complexity = 22
74-
max-line-length = 120
75-
unused-arguments-ignore-abstract-functions = true
76-
noqa-require-code = true
77-
dictionaries = ["en_US", "python", "technical", "django"]
78-
7974
[tool.coverage]
8075
html.show_contexts = true
8176
html.skip_covered = false
@@ -98,5 +93,26 @@ show_error_codes = true
9893
strict = true
9994
overrides = [{ module = ["virtualenv.*"], ignore_missing_imports = true }]
10095

101-
[tool.pep8]
102-
max-line-length = "120"
96+
[tool.ruff]
97+
select = ["ALL"]
98+
line-length = 120
99+
target-version = "py37"
100+
isort = {known-first-party = ["pyproject_api"], required-imports = ["from __future__ import annotations"]}
101+
ignore = [
102+
"INP001", # no implicit namespaces here
103+
"ANN101", # Missing type annotation for `self` in method
104+
"ANN102", # Missing type annotation for `cls` in classmethod"
105+
"ANN401", # Dynamically typed expressions
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+
]

src/pyproject_api/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""PyProject API interface."""
12
from __future__ import annotations
23

34
from ._frontend import (

src/pyproject_api/__main__.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
from __future__ import annotations
1+
from __future__ import annotations # noqa: D100
22

33
import argparse
44
import os
55
import pathlib
66
import sys
7+
from typing import TYPE_CHECKING
78

8-
from ._frontend import EditableResult, SdistResult, WheelResult
99
from ._via_fresh_subprocess import SubprocessFrontend
1010

11+
if TYPE_CHECKING:
12+
from ._frontend import EditableResult, SdistResult, WheelResult
1113

12-
def main_parser() -> argparse.ArgumentParser:
14+
15+
def main_parser() -> argparse.ArgumentParser: # noqa: D103
1316
parser = argparse.ArgumentParser(
1417
description=(
1518
"A pyproject.toml-based build frontend. "
@@ -58,7 +61,7 @@ def main_parser() -> argparse.ArgumentParser:
5861
return parser
5962

6063

61-
def main(argv: list[str]) -> None:
64+
def main(argv: list[str]) -> None: # noqa: D103
6265
parser = main_parser()
6366
args = parser.parse_args(argv)
6467

@@ -70,22 +73,22 @@ def main(argv: list[str]) -> None:
7073
res: SdistResult | WheelResult | EditableResult
7174

7275
if "sdist" in distributions:
73-
print("Building sdist...")
76+
print("Building sdist...") # noqa: T201
7477
res = frontend.build_sdist(outdir)
75-
print(res.out)
76-
print(res.err, file=sys.stderr)
78+
print(res.out) # noqa: T201
79+
print(res.err, file=sys.stderr) # noqa: T201
7780

7881
if "wheel" in distributions:
79-
print("Building wheel...")
82+
print("Building wheel...") # noqa: T201
8083
res = frontend.build_wheel(outdir)
81-
print(res.out)
82-
print(res.err, file=sys.stderr)
84+
print(res.out) # noqa: T201
85+
print(res.err, file=sys.stderr) # noqa: T201
8386

8487
if "editable" in distributions:
85-
print("Building editable wheel...")
88+
print("Building editable wheel...") # noqa: T201
8689
res = frontend.build_editable(outdir)
87-
print(res.out)
88-
print(res.err, file=sys.stderr)
90+
print(res.out) # noqa: T201
91+
print(res.err, file=sys.stderr) # noqa: T201
8992

9093

9194
if __name__ == "__main__":

src/pyproject_api/_backend.pyi

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
"""Handles communication on the backend side between frontend and backend"""
2-
from typing import Any, Optional, Sequence
1+
from typing import Any, Sequence
32

4-
class MissingCommand(TypeError): ...
3+
class MissingCommand(TypeError): ... # noqa: N818
54

65
class BackendProxy:
76
backend_module: str
8-
backend_object: Optional[str]
7+
backend_object: str | None
98
backend: Any
10-
def __init__(self, backend_module: str, backend_obj: Optional[str]) -> None: ...
9+
def __init__(self, backend_module: str, backend_obj: str | None) -> None: ...
1110
def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: ...
12-
def __str__(self) -> str: ...
1311
def _exit(self) -> None: ...
1412
def _optional_commands(self) -> dict[str, bool]: ...
1513

0 commit comments

Comments
 (0)