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

[pre-commit.ci] pre-commit autoupdate #682

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
24 changes: 12 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,35 @@ repos:
language: system
always_run: true
pass_filenames: false
stages: [commit]
stages: [pre-commit]
- id: autofix-docs
name: Autofix ReST documentation from docstrings and TOML
entry: poetry run python3 docs/autofix_docs.py
language: system
always_run: true
pass_filenames: false
types: [python, toml]
stages: [commit]
stages: [pre-commit]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/google/keep-sorted
rev: v0.5.0
rev: v0.6.0
hooks:
- id: keep-sorted
- repo: https://github.com/pappasam/toml-sort
rev: v0.23.1
rev: v0.24.2
hooks:
- id: toml-sort-fix
# Don't sort certain TOML files:
# - style-related files: used to generate YAML that might depend on the order
# - poetry.lock: auto-generated file
exclude: (ideas/|resources/|tests/|poetry.lock)
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.8
rev: v0.11.2
hooks:
- id: ruff
args: [--fix]
Expand All @@ -62,16 +62,16 @@ repos:
hooks:
- id: pydocstringformatter
- repo: https://github.com/aio-libs/sort-all # TODO: style(pre-commit): add sort-all
rev: v1.2.0
rev: v1.3.0
hooks:
- id: sort-all
- repo: https://github.com/psf/black
rev: 24.8.0
rev: 25.1.0
hooks:
- id: black
args: [--safe, --quiet]
- repo: https://github.com/asottile/blacken-docs
rev: 1.18.0
rev: 1.19.1
hooks:
- id: blacken-docs
additional_dependencies: [black==23.7.0]
Expand All @@ -84,9 +84,9 @@ repos:
rev: v4.0.0-alpha.8
hooks:
- id: prettier
stages: [commit]
stages: [pre-commit]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.2
rev: v1.15.0
hooks:
- id: mypy
# https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-show-error-codes
Expand Down Expand Up @@ -131,7 +131,7 @@ repos:
# https://docs.openstack.org/bashate/latest/man/bashate.html#options
args: [-i, E006]
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.29.1
rev: v4.4.1
hooks:
- id: commitizen
stages: [commit-msg]
8 changes: 4 additions & 4 deletions src/nitpick/blender.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class ElementDetail: # pylint: disable=too-few-public-methods
@property
def cast_to_dict(self) -> JsonDict:
"""Data cast to dict, for mypy."""
return cast(JsonDict, self.data)
return cast("JsonDict", self.data)

@classmethod
def from_data(cls, index: int, data: ElementData, jmes_key: str) -> ElementDetail:
Expand Down Expand Up @@ -394,7 +394,7 @@ def _compare_list_elements( # pylint: disable=too-many-arguments
actual_element.cast_to_dict, expected_element.cast_to_dict, return_list=False
)
if diff:
new_block = cast(JsonDict, actual_element.data).copy()
new_block = cast("JsonDict", actual_element.data).copy()
new_block.update(diff)
display.append(new_block)
replace[actual_element.index] = new_block
Expand All @@ -418,8 +418,8 @@ def _compare_children(
expected_nested = search_json(expected_element.data, jmes_nested, [{}])
diff_nested = compare_lists_with_dictdiffer(actual_nested, expected_nested, return_list=True)
if diff_nested:
actual_data = cast(JsonDict, actual_element.data)
expected_data = cast(JsonDict, expected_element.data)
actual_data = cast("JsonDict", actual_element.data)
expected_data = cast("JsonDict", expected_element.data)
# TODO: fix: set value deep down the tree (try dpath-python). parent_key = 'regions[].cities[].people'
expected_data[parent_key] = diff_nested

Expand Down
2 changes: 1 addition & 1 deletion src/nitpick/plugins/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def enforce_rules(self) -> Iterator[Fuss]:
def expected_dict_from_contains_keys(self):
"""Expected dict created from "contains_keys" values."""
return unflatten_quotes(
{key: VALUE_PLACEHOLDER for key in set(self.expected_config.get(KEY_CONTAINS_KEYS) or [])}
dict.fromkeys(set(self.expected_config.get(KEY_CONTAINS_KEYS) or []), VALUE_PLACEHOLDER)
)

def expected_dict_from_contains_json(self):
Expand Down
10 changes: 5 additions & 5 deletions src/nitpick/plugins/toml.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ def enforce_rules(self) -> Iterator[Fuss]:

document = parse(toml_doc.as_string) if self.autofix else None
yield from chain(
self.report(SharedViolations.DIFFERENT_VALUES, document, cast(TomlDoc, comparison.diff)),
self.report(SharedViolations.DIFFERENT_VALUES, document, cast("TomlDoc", comparison.diff)),
self.report(
SharedViolations.MISSING_VALUES,
document,
cast(TomlDoc, comparison.missing),
cast(TomlDoc, comparison.replace),
cast("TomlDoc", comparison.missing),
cast("TomlDoc", comparison.replace),
),
)
if self.autofix and self.dirty:
Expand All @@ -65,11 +65,11 @@ def report(
if not (change or replacement):
return
if self.autofix:
real_change = cast(TomlDoc, replacement or change)
real_change = cast("TomlDoc", replacement or change)
traverse_toml_tree(document, real_change.as_object)
self.dirty = True

to_display = cast(TomlDoc, change or replacement)
to_display = cast("TomlDoc", change or replacement)
yield self.reporter.make_fuss(violation, to_display.reformatted.strip(), prefix="", fixed=self.autofix)

@property
Expand Down
10 changes: 5 additions & 5 deletions src/nitpick/plugins/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ def enforce_rules(self) -> Iterator[Fuss]:
return

yield from chain(
self.report(SharedViolations.DIFFERENT_VALUES, yaml_doc.as_object, cast(YamlDoc, comparison.diff)),
self.report(SharedViolations.DIFFERENT_VALUES, yaml_doc.as_object, cast("YamlDoc", comparison.diff)),
self.report(
SharedViolations.MISSING_VALUES,
yaml_doc.as_object,
cast(YamlDoc, comparison.missing),
cast(YamlDoc, comparison.replace),
cast("YamlDoc", comparison.missing),
cast("YamlDoc", comparison.replace),
),
)
if self.autofix and self.dirty:
Expand Down Expand Up @@ -121,11 +121,11 @@ def report(
if not (change or replacement):
return
if self.autofix:
real_change = cast(YamlDoc, replacement or change)
real_change = cast("YamlDoc", replacement or change)
traverse_yaml_tree(yaml_object, real_change.as_object)
self.dirty = True

to_display = cast(YamlDoc, change or replacement)
to_display = cast("YamlDoc", change or replacement)
yield self.reporter.make_fuss(violation, to_display.reformatted.strip(), prefix="", fixed=self.autofix)

@property
Expand Down
6 changes: 3 additions & 3 deletions src/nitpick/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,12 +667,12 @@ def api_url(self) -> furl:
@property
def short_protocol_url(self) -> furl:
"""Short protocol URL (``gh``)."""
return self._build_url(cast(str, Scheme.GH))
return self._build_url(cast("str", Scheme.GH))

@property
def long_protocol_url(self) -> furl:
"""Long protocol URL (``github``)."""
return self._build_url(cast(str, Scheme.GITHUB))
return self._build_url(cast("str", Scheme.GITHUB))

def _build_url(self, scheme: str) -> furl:
if self.git_reference and self.git_reference != self.default_branch:
Expand Down Expand Up @@ -776,7 +776,7 @@ class PythonPackageFetcher(StyleFetcher): # pylint: disable=too-few-public-meth

def _normalize_scheme(self, scheme: str) -> str: # noqa: ARG002
# Always use the shorter py:// scheme name in the canonical URL.
return cast(str, Scheme.PY)
return cast("str", Scheme.PY)

def fetch(self, url: furl) -> str:
"""Fetch the style from a Python package."""
Expand Down
Loading