Skip to content

Commit 627b004

Browse files
authored
Add and enforce newer linting config (#392)
- update various - switch to black mirror - add flake8-typing-as-t - add flake8-comprehensions - add slyp
1 parent d1665f0 commit 627b004

File tree

6 files changed

+37
-23
lines changed

6 files changed

+37
-23
lines changed

.pre-commit-config.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
repos:
22
# dogfood
33
- repo: https://github.com/python-jsonschema/check-jsonschema
4-
rev: 0.27.3
4+
rev: 0.27.4
55
hooks:
66
- id: check-dependabot
77
- id: check-github-workflows
@@ -18,15 +18,22 @@ repos:
1818
hooks:
1919
- id: check-merge-conflict
2020
- id: trailing-whitespace
21-
- repo: https://github.com/psf/black
21+
- repo: https://github.com/psf/black-pre-commit-mirror
2222
rev: 24.1.1
2323
hooks:
2424
- id: black
2525
- repo: https://github.com/PyCQA/flake8
2626
rev: 7.0.0
2727
hooks:
2828
- id: flake8
29-
additional_dependencies: ['flake8-bugbear==23.7.10']
29+
additional_dependencies:
30+
- 'flake8-bugbear==24.1.17'
31+
- 'flake8-typing-as-t==0.0.3'
32+
- 'flake8-comprehensions==3.14.0'
33+
- repo: https://github.com/sirosen/slyp
34+
rev: 0.3.0
35+
hooks:
36+
- id: slyp
3037
- repo: https://github.com/PyCQA/isort
3138
rev: 5.13.2
3239
hooks:

scripts/vendor-schemas.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,9 @@ def _save_new_hash(name: str, digest: str) -> None:
107107
for name in UPDATED_SCHEMAS:
108108
digest = file2digest(schema2filename(name))
109109

110-
# new file, changes were made and hash should update
111-
if name not in OLD_HASHES:
112-
_save_new_hash(name, digest)
113-
110+
# new file, changes were made and hash should update, OR
114111
# if the existing hash does not match the new hash, save the new one
115-
elif digest != OLD_HASHES[name]:
112+
if name not in OLD_HASHES or digest != OLD_HASHES[name]:
116113
_save_new_hash(name, digest)
117114

118115

src/check_jsonschema/catalog.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ def _githubusercontent_url(owner: str, repo: str, ref: str, path: str) -> str:
2727
),
2828
"hook_config": {
2929
"name": "Validate Azure Pipelines",
30-
"description": "Validate Azure Pipelines config against the schema provided "
31-
"by Microsoft",
30+
"description": (
31+
"Validate Azure Pipelines config against the schema provided "
32+
"by Microsoft"
33+
),
3234
"add_args": ["--data-transform", "azure-pipelines"],
3335
"files": r"^(\.)?azure-pipelines\.(yml|yaml)$",
3436
"types": "yaml",
@@ -112,8 +114,10 @@ def _githubusercontent_url(owner: str, repo: str, ref: str, path: str) -> str:
112114
},
113115
},
114116
"gitlab-ci": {
115-
"url": "https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts"
116-
"/editor/schema/ci.json",
117+
"url": (
118+
"https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts"
119+
"/editor/schema/ci.json"
120+
),
117121
"hook_config": {
118122
"name": "Validate GitLab CI config",
119123
"add_args": ["--data-transform", "gitlab-ci"],
@@ -130,8 +134,10 @@ def _githubusercontent_url(owner: str, repo: str, ref: str, path: str) -> str:
130134
),
131135
"hook_config": {
132136
"name": "Validate ReadTheDocs Config",
133-
"description": "Validate ReadTheDocs config against the schema "
134-
"provided by ReadTheDocs",
137+
"description": (
138+
"Validate ReadTheDocs config against the schema "
139+
"provided by ReadTheDocs"
140+
),
135141
"files": r"^\.readthedocs\.(yml|yaml)$",
136142
"types": "yaml",
137143
},
@@ -140,8 +146,10 @@ def _githubusercontent_url(owner: str, repo: str, ref: str, path: str) -> str:
140146
"url": "https://docs.renovatebot.com/renovate-schema.json",
141147
"hook_config": {
142148
"name": "Validate Renovate Config",
143-
"description": "Validate Renovate config against the schema provided by "
144-
"Renovate (does not support renovate config in package.json)",
149+
"description": (
150+
"Validate Renovate config against the schema provided by "
151+
"Renovate (does not support renovate config in package.json)"
152+
),
145153
"files": [
146154
r"renovate\.(json|json5)",
147155
r"\.(github|gitlab)/renovate\.(json|json5)",
@@ -158,8 +166,10 @@ def _githubusercontent_url(owner: str, repo: str, ref: str, path: str) -> str:
158166
},
159167
},
160168
"woodpecker-ci": {
161-
"url": "https://raw.githubusercontent.com/woodpecker-ci/woodpecker/main/pipeline"
162-
"/frontend/yaml/linter/schema/schema.json",
169+
"url": (
170+
"https://raw.githubusercontent.com/woodpecker-ci/woodpecker/main/pipeline"
171+
"/frontend/yaml/linter/schema/schema.json"
172+
),
163173
"hook_config": {
164174
"name": "Validate Woodpecker Config",
165175
"files": [

src/check_jsonschema/cli/main_command.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,10 @@ def pretty_helptext_list(values: list[str] | tuple[str, ...]) -> str:
139139
@click.option(
140140
"--disable-formats",
141141
multiple=True,
142-
help="Disable specific format checks in the schema. "
143-
"Pass '*' to disable all format checks.",
142+
help=(
143+
"Disable specific format checks in the schema. "
144+
"Pass '*' to disable all format checks."
145+
),
144146
type=CommaDelimitedList(choices=("*", *KNOWN_FORMATS)),
145147
metavar="{*|FORMAT,FORMAT,...}",
146148
)

src/check_jsonschema/transforms/azure_pipelines.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ def traverse_list(data: list) -> list:
6969

7070
if isinstance(item_value, list):
7171
ret.extend(item_value)
72-
elif isinstance(item_value, dict):
73-
ret.append(item_value)
7472
else:
7573
ret.append(item_value)
7674
# not expression? process the item and append

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def mock_module(tmp_path, monkeypatch):
2121

2222
def func(path, text):
2323
path = pathlib.Path(path)
24-
mod_dir = tmp_path / (path.parent)
24+
mod_dir = tmp_path / path.parent
2525
mod_dir.mkdir(parents=True, exist_ok=True)
2626
for part in path.parts[:-1]:
2727
(tmp_path / part / "__init__.py").touch()

0 commit comments

Comments
 (0)