Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add and enforce newer linting config #392

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:
# dogfood
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.3
rev: 0.27.4
hooks:
- id: check-dependabot
- id: check-github-workflows
Expand All @@ -18,15 +18,22 @@ repos:
hooks:
- id: check-merge-conflict
- id: trailing-whitespace
- repo: https://github.com/psf/black
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.1.1
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies: ['flake8-bugbear==23.7.10']
additional_dependencies:
- 'flake8-bugbear==24.1.17'
- 'flake8-typing-as-t==0.0.3'
- 'flake8-comprehensions==3.14.0'
- repo: https://github.com/sirosen/slyp
rev: 0.3.0
hooks:
- id: slyp
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
Expand Down
7 changes: 2 additions & 5 deletions scripts/vendor-schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,9 @@ def _save_new_hash(name: str, digest: str) -> None:
for name in UPDATED_SCHEMAS:
digest = file2digest(schema2filename(name))

# new file, changes were made and hash should update
if name not in OLD_HASHES:
_save_new_hash(name, digest)

# new file, changes were made and hash should update, OR
# if the existing hash does not match the new hash, save the new one
elif digest != OLD_HASHES[name]:
if name not in OLD_HASHES or digest != OLD_HASHES[name]:
_save_new_hash(name, digest)


Expand Down
30 changes: 20 additions & 10 deletions src/check_jsonschema/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ def _githubusercontent_url(owner: str, repo: str, ref: str, path: str) -> str:
),
"hook_config": {
"name": "Validate Azure Pipelines",
"description": "Validate Azure Pipelines config against the schema provided "
"by Microsoft",
"description": (
"Validate Azure Pipelines config against the schema provided "
"by Microsoft"
),
"add_args": ["--data-transform", "azure-pipelines"],
"files": r"^(\.)?azure-pipelines\.(yml|yaml)$",
"types": "yaml",
Expand Down Expand Up @@ -112,8 +114,10 @@ def _githubusercontent_url(owner: str, repo: str, ref: str, path: str) -> str:
},
},
"gitlab-ci": {
"url": "https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts"
"/editor/schema/ci.json",
"url": (
"https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts"
"/editor/schema/ci.json"
),
"hook_config": {
"name": "Validate GitLab CI config",
"add_args": ["--data-transform", "gitlab-ci"],
Expand All @@ -130,8 +134,10 @@ def _githubusercontent_url(owner: str, repo: str, ref: str, path: str) -> str:
),
"hook_config": {
"name": "Validate ReadTheDocs Config",
"description": "Validate ReadTheDocs config against the schema "
"provided by ReadTheDocs",
"description": (
"Validate ReadTheDocs config against the schema "
"provided by ReadTheDocs"
),
"files": r"^\.readthedocs\.(yml|yaml)$",
"types": "yaml",
},
Expand All @@ -140,8 +146,10 @@ def _githubusercontent_url(owner: str, repo: str, ref: str, path: str) -> str:
"url": "https://docs.renovatebot.com/renovate-schema.json",
"hook_config": {
"name": "Validate Renovate Config",
"description": "Validate Renovate config against the schema provided by "
"Renovate (does not support renovate config in package.json)",
"description": (
"Validate Renovate config against the schema provided by "
"Renovate (does not support renovate config in package.json)"
),
"files": [
r"renovate\.(json|json5)",
r"\.(github|gitlab)/renovate\.(json|json5)",
Expand All @@ -158,8 +166,10 @@ def _githubusercontent_url(owner: str, repo: str, ref: str, path: str) -> str:
},
},
"woodpecker-ci": {
"url": "https://raw.githubusercontent.com/woodpecker-ci/woodpecker/main/pipeline"
"/frontend/yaml/linter/schema/schema.json",
"url": (
"https://raw.githubusercontent.com/woodpecker-ci/woodpecker/main/pipeline"
"/frontend/yaml/linter/schema/schema.json"
),
"hook_config": {
"name": "Validate Woodpecker Config",
"files": [
Expand Down
6 changes: 4 additions & 2 deletions src/check_jsonschema/cli/main_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,10 @@ def pretty_helptext_list(values: list[str] | tuple[str, ...]) -> str:
@click.option(
"--disable-formats",
multiple=True,
help="Disable specific format checks in the schema. "
"Pass '*' to disable all format checks.",
help=(
"Disable specific format checks in the schema. "
"Pass '*' to disable all format checks."
),
type=CommaDelimitedList(choices=("*", *KNOWN_FORMATS)),
metavar="{*|FORMAT,FORMAT,...}",
)
Expand Down
2 changes: 0 additions & 2 deletions src/check_jsonschema/transforms/azure_pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ def traverse_list(data: list) -> list:

if isinstance(item_value, list):
ret.extend(item_value)
elif isinstance(item_value, dict):
ret.append(item_value)
else:
ret.append(item_value)
# not expression? process the item and append
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def mock_module(tmp_path, monkeypatch):

def func(path, text):
path = pathlib.Path(path)
mod_dir = tmp_path / (path.parent)
mod_dir = tmp_path / path.parent
mod_dir.mkdir(parents=True, exist_ok=True)
for part in path.parts[:-1]:
(tmp_path / part / "__init__.py").touch()
Expand Down
Loading