Skip to content

Commit ea6452f

Browse files
committed
flake8 -> ruff
1 parent 4e8b912 commit ea6452f

File tree

6 files changed

+71
-22
lines changed

6 files changed

+71
-22
lines changed

Diff for: .pre-commit-config.yaml

+4-12
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,14 @@ repos:
1414
- id: mixed-line-ending
1515
args: [--fix, lf]
1616
- id: trailing-whitespace
17+
- repo: https://github.com/charliermarsh/ruff-pre-commit
18+
rev: "v0.0.270"
19+
hooks:
20+
- id: ruff
1721
- repo: https://github.com/PyCQA/isort
1822
rev: 5.12.0
1923
hooks:
2024
- id: isort
21-
- repo: https://github.com/PyCQA/flake8
22-
rev: "6.0.0"
23-
hooks:
24-
- id: flake8
25-
- repo: https://github.com/asottile/yesqa
26-
rev: v1.4.0
27-
hooks:
28-
- id: yesqa
29-
- repo: https://github.com/asottile/pyupgrade
30-
rev: v3.4.0
31-
hooks:
32-
- id: pyupgrade
3325
- repo: https://github.com/psf/black
3426
rev: 23.3.0
3527
hooks:

Diff for: jsonschema_specifications/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
"""
2+
The JSON Schema meta-schemas and vocabularies, exposed as a Registry.
3+
"""
14
from referencing import Registry as _Registry
25
from referencing.jsonschema import SchemaRegistry as _SchemaRegistry
36

Diff for: jsonschema_specifications/_core.py

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ def _schemas():
1616
"""
1717
All schemas we ship.
1818
"""
19-
2019
# importlib.resources.abc.Traversal doesn't have nice ways to do this that
2120
# I'm aware of...
2221
#
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
from collections.abc import Mapping
2+
13
from jsonschema_specifications import REGISTRY
24

35

46
def test_it_contains_metaschemas():
57
schema = REGISTRY.contents("http://json-schema.org/draft-07/schema#")
8+
assert isinstance(schema, Mapping)
69
assert schema["$id"] == "http://json-schema.org/draft-07/schema#"
710
assert schema["title"] == "Core schema meta-schema"

Diff for: noxfile.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ def tests(session):
2626
session.run("pytest", "--verbosity=3")
2727

2828

29+
@session()
30+
def audit(session):
31+
session.install("pip-audit", ROOT)
32+
session.run("python", "-m", "pip_audit")
33+
34+
2935
@session(tags=["build"])
3036
def build(session):
3137
session.install("build")
@@ -43,15 +49,8 @@ def readme(session):
4349

4450
@session(tags=["style"])
4551
def style(session):
46-
session.install(
47-
"flake8",
48-
"flake8-broken-line",
49-
"flake8-bugbear",
50-
"flake8-commas",
51-
"flake8-quotes",
52-
"flake8-tidy-imports",
53-
)
54-
session.run("python", "-m", "flake8", PACKAGE, __file__)
52+
session.install("ruff")
53+
session.run("ruff", "check", ROOT)
5554

5655

5756
@session()

Diff for: pyproject.toml

+53
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,23 @@ Issues = "https://github.com/python-jsonschema/jsonschema-specifications/issues/
4949
Funding = "https://github.com/sponsors/Julian"
5050
Source = "https://github.com/python-jsonschema/jsonschema-specifications"
5151

52+
[tool.coverage.html]
53+
show_contexts = true
54+
skip_covered = false
55+
5256
[tool.coverage.run]
5357
branch = true
5458
source = ["jsonschema-specifications"]
5559
dynamic_context = "test_function"
5660

5761
[tool.coverage.report]
62+
exclude_also = [
63+
"if TYPE_CHECKING:",
64+
"\\s*\\.\\.\\.\\s*",
65+
]
5866
fail_under = 100
67+
show_missing = true
68+
skip_covered = true
5969

6070
[tool.doc8]
6171
ignore = [
@@ -68,3 +78,46 @@ ensure_newline_before_comments = true
6878
from_first = true
6979
include_trailing_comma = true
7080
multi_line_output = 3
81+
82+
[tool.ruff]
83+
line-length = 79
84+
target-version = "py38"
85+
select = ["ANN", "B", "D", "E", "F", "Q", "UP", "W"]
86+
ignore = [
87+
# Wat, type annotations for self and cls, why is this a thing?
88+
"ANN101",
89+
"ANN102",
90+
# Private annotations are fine to leave out.
91+
"ANN202",
92+
# I don't know how to more properly annotate "pass along all arguments".
93+
"ANN401",
94+
# raise SomeException(...) is fine.
95+
"B904",
96+
# It's fine to not have docstrings for magic methods.
97+
"D105",
98+
# This rule makes diffs uglier when expanding docstrings (and it's uglier)
99+
"D200",
100+
# No blank lines before docstrings.
101+
"D203",
102+
# Start docstrings on the second line.
103+
"D212",
104+
# This rule misses sassy docstrings ending with ! or ?.
105+
"D400",
106+
# Section headers should end with a colon not a newline
107+
"D406",
108+
# Underlines aren't needed
109+
"D407",
110+
# Plz spaces after section headers
111+
"D412",
112+
# We support 3.8 + 3.9
113+
"UP007",
114+
]
115+
extend-exclude = ["suite"]
116+
117+
[tool.ruff.flake8-quotes]
118+
docstring-quotes = "double"
119+
120+
[tool.ruff.per-file-ignores]
121+
"docs/*" = ["ANN", "D"]
122+
"jsonschema_specifications/tests/*" = ["ANN", "D"]
123+
"noxfile.py" = ["ANN", "D"]

0 commit comments

Comments
 (0)