Skip to content

Commit

Permalink
MAINT: update lock files (#467)
Browse files Browse the repository at this point in the history
* MAINT: fix Ruff linting errors
  • Loading branch information
redeboer authored Dec 3, 2024
1 parent e6ddbf2 commit 4463ebb
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 37 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
- id: check-useless-excludes

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.1
rev: v0.8.1
hooks:
- id: ruff
args: [--fix]
Expand Down Expand Up @@ -61,7 +61,7 @@ repos:
files: ^\.pre\-commit\-(config|hooks)\.yaml$

- repo: https://github.com/ComPWA/prettier-pre-commit
rev: v3.3.3
rev: v3.4.1
hooks:
- id: prettier

Expand All @@ -71,14 +71,14 @@ repos:
- id: taplo-format

- repo: https://github.com/pappasam/toml-sort
rev: v0.23.1
rev: v0.24.2
hooks:
- id: toml-sort
args: [--in-place]
exclude: (?x)^(labels/.*\.toml)$

- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v8.15.2
rev: v8.16.0
hooks:
- id: cspell

Expand All @@ -104,6 +104,6 @@ repos:
- python

- repo: https://github.com/ComPWA/pyright-pre-commit
rev: v1.1.386
rev: v1.1.389
hooks:
- id: pyright
2 changes: 1 addition & 1 deletion src/compwa_policy/check_dev_files/citation.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def add_json_schema_precommit(precommit: ModifiablePrecommit) -> None:
else:
existing_hooks[hook_idx] = expected_hook
existing_repos = precommit.document["repos"]
repos_yaml = cast(CommentedSeq, existing_repos)
repos_yaml = cast("CommentedSeq", existing_repos)
repos_yaml.yaml_set_comment_before_after_key(repo_idx + 1, before="\n")
msg = f"Updated pre-commit hook {repo_url}"
precommit.changelog.append(msg)
Expand Down
6 changes: 3 additions & 3 deletions src/compwa_policy/check_dev_files/precommit.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
from pathlib import Path
from typing import TYPE_CHECKING, cast

from ruamel.yaml.comments import CommentedMap

from compwa_policy.errors import PrecommitError
from compwa_policy.utilities import CONFIG_PATH
from compwa_policy.utilities.executor import Executor
Expand All @@ -17,6 +15,8 @@
from compwa_policy.utilities.yaml import create_prettier_round_trip_yaml

if TYPE_CHECKING:
from ruamel.yaml.comments import CommentedMap

from compwa_policy.utilities.precommit import (
ModifiablePrecommit,
Precommit,
Expand Down Expand Up @@ -118,7 +118,7 @@ def _update_precommit_ci_skip(precommit: ModifiablePrecommit) -> None:
existing_skips = precommit_ci.get("skip")
if existing_skips != expected_skips:
precommit_ci["skip"] = sorted(expected_skips)
yaml_config = cast(CommentedMap, precommit.document)
yaml_config = cast("CommentedMap", precommit.document)
yaml_config.yaml_set_comment_before_after_key("repos", before="\n")
msg = "Updated ci.skip section"
precommit.changelog.append(msg)
Expand Down
11 changes: 6 additions & 5 deletions src/compwa_policy/check_dev_files/readthedocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from textwrap import dedent, indent
from typing import IO, TYPE_CHECKING, Callable, cast

from ruamel.yaml.comments import CommentedMap
from ruamel.yaml.scalarstring import DoubleQuotedScalarString, LiteralScalarString

from compwa_policy.errors import PrecommitError
Expand All @@ -17,6 +16,8 @@
from compwa_policy.utilities.yaml import create_prettier_round_trip_yaml

if TYPE_CHECKING:
from ruamel.yaml.comments import CommentedMap

from compwa_policy.check_dev_files.conda import PackageManagerChoice
from compwa_policy.utilities.pyproject.getters import PythonVersion

Expand Down Expand Up @@ -51,7 +52,7 @@ def main(


def _update_os(config: ReadTheDocs) -> None:
build = cast(CommentedMap, config.document.get("build"))
build = cast("CommentedMap", config.document.get("build"))
if build is None:
return
os: str | None = build.get("os")
Expand All @@ -64,7 +65,7 @@ def _update_os(config: ReadTheDocs) -> None:


def _update_python_version(config: ReadTheDocs, python_version: PythonVersion) -> None:
tools = cast(CommentedMap, config.document.get("build", {}).get("tools"))
tools = cast("CommentedMap", config.document.get("build", {}).get("tools"))
if tools is None:
return
existing_version: str | None = tools.get("python")
Expand Down Expand Up @@ -307,9 +308,9 @@ def __init__(self, source: IO | Path | str) -> None:
self.source = source
if isinstance(source, (Path, str)):
with open(source) as f:
self.document = cast(dict, self.__parser.load(f))
self.document = cast("dict", self.__parser.load(f))
else:
self.document = cast(dict, self.__parser.load(source))
self.document = cast("dict", self.__parser.load(source))

def dump(self, target: IO | Path | str | None = None) -> None:
if target is None:
Expand Down
6 changes: 3 additions & 3 deletions src/compwa_policy/utilities/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
from typing import ParamSpec
else:
from typing_extensions import ParamSpec
if sys.version_info < (3, 11):
from typing_extensions import Self
else:
if sys.version_info >= (3, 11):
from typing import Self
else:
from typing_extensions import Self

T = TypeVar("T")
P = ParamSpec("P")
Expand Down
6 changes: 3 additions & 3 deletions src/compwa_policy/utilities/precommit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
)
from compwa_policy.utilities.yaml import create_prettier_round_trip_yaml

if sys.version_info < (3, 11):
from typing_extensions import Self
else:
if sys.version_info >= (3, 11):
from typing import Self
else:
from typing_extensions import Self

if TYPE_CHECKING:
from types import TracebackType
Expand Down
6 changes: 3 additions & 3 deletions src/compwa_policy/utilities/precommit/setters.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def update_single_hook_precommit_repo(
expected_yaml.pop("rev", None)
expected_yaml.insert(1, "rev", "PLEASE-UPDATE")
idx = _determine_expected_repo_index(precommit.document, hook_id)
repos_yaml = cast(CommentedSeq, repos)
repos_yaml = cast("CommentedSeq", repos)
repos_yaml.insert(idx, expected_yaml)
if isinstance(repos_yaml, CommentedSeq):
repos_yaml.yaml_set_comment_before_after_key(
Expand All @@ -81,7 +81,7 @@ def update_single_hook_precommit_repo(
if existing_rev is not None:
expected_yaml.insert(1, "rev", PlainScalarString(existing_rev))
repos[idx] = expected_yaml # type: ignore[assignment,call-overload]
repos_map = cast(CommentedMap, repos)
repos_map = cast("CommentedMap", repos)
repos_map.yaml_set_comment_before_after_key(idx + 1, before="\n")
msg = f"Updated {hook_id} hook"
precommit.changelog.append(msg)
Expand Down Expand Up @@ -126,7 +126,7 @@ def update_precommit_hook(
hook_idx = __determine_expected_hook_idx(hooks, expected_hook["id"])
hooks.insert(hook_idx, expected_hook)
if hook_idx == len(hooks) - 1:
repos = cast(CommentedMap, precommit.document["repos"][hook_idx])
repos = cast("CommentedMap", precommit.document["repos"][hook_idx])
repos.yaml_set_comment_before_after_key(repo_idx + 1, before="\n")
msg = f"Added {expected_hook['id']!r} to {repo_name} pre-commit config"
precommit.changelog.append(msg)
Expand Down
6 changes: 3 additions & 3 deletions src/compwa_policy/utilities/precommit/struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from functools import cache
from typing import ForwardRef, Literal, TypedDict

if sys.version_info < (3, 11):
from typing_extensions import NotRequired
else:
if sys.version_info >= (3, 11):
from typing import NotRequired
else:
from typing_extensions import NotRequired


class PrecommitConfig(TypedDict):
Expand Down
10 changes: 5 additions & 5 deletions src/compwa_policy/utilities/pyproject/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
remove_dependency,
)

if sys.version_info < (3, 11):
from typing_extensions import Self
else:
if sys.version_info >= (3, 11):
from typing import Self
if sys.version_info < (3, 12):
from typing_extensions import override
else:
from typing_extensions import Self
if sys.version_info >= (3, 12):
from typing import override
else:
from typing_extensions import override
if TYPE_CHECKING:
from collections.abc import Iterable, Mapping, MutableMapping, Sequence
from types import TracebackType
Expand Down
7 changes: 3 additions & 4 deletions src/compwa_policy/utilities/pyproject/_struct.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# noqa: A005
"""This module is hidden Sphinx can't handle `typing.TypedDict` with hyphens.
See https://github.com/sphinx-doc/sphinx/issues/11039.
Expand All @@ -7,10 +6,10 @@
import sys
from typing import TypedDict

if sys.version_info < (3, 11):
from typing_extensions import NotRequired
else:
if sys.version_info >= (3, 11):
from typing import NotRequired
else:
from typing_extensions import NotRequired

IncludeGroup = TypedDict("IncludeGroup", {"include-group": str})
PyprojectTOML = TypedDict(
Expand Down
5 changes: 3 additions & 2 deletions src/compwa_policy/utilities/pyproject/setters.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import itertools
import re
from collections import abc
from collections.abc import Iterable, Mapping, MutableMapping, Sequence
from typing import TYPE_CHECKING, Any, cast

import tomlkit
Expand All @@ -17,6 +16,8 @@
from compwa_policy.utilities.toml import to_toml_array

if TYPE_CHECKING:
from collections.abc import Iterable, Mapping, MutableMapping, Sequence

from tomlkit.items import Table

from compwa_policy.utilities.pyproject._struct import IncludeGroup, PyprojectTOML
Expand Down Expand Up @@ -126,7 +127,7 @@ def get_sub_table(
) -> MutableMapping[str, Any]:
create_sub_table(config, dotted_header)
table = get_immutable_sub_table(config, dotted_header)
return cast(MutableMapping[str, Any], table)
return cast("MutableMapping[str, Any]", table)


def remove_dependency( # noqa: C901, PLR0912
Expand Down

0 comments on commit 4463ebb

Please sign in to comment.