diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 415540bc..bb212463 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,19 +1,19 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 + rev: v6.0.0 hooks: - id: check-added-large-files - id: trailing-whitespace - id: end-of-file-fixer - id: mixed-line-ending - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.9.9" + rev: "v0.14.7" hooks: - id: ruff args: ["--fix"] - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy - rev: "v1.15.0" + rev: "v1.19.0" hooks: - id: mypy additional_dependencies: ["types-PyYAML", "types-setuptools"] diff --git a/unidep/_conda_env.py b/unidep/_conda_env.py index 6f08448b..6140e03a 100644 --- a/unidep/_conda_env.py +++ b/unidep/_conda_env.py @@ -52,7 +52,7 @@ def _conda_sel(sel: str) -> CondaPlatform: """Return the allowed `sel(platform)` string.""" _platform = sel.split("-", 1)[0] assert _platform in get_args(CondaPlatform), f"Invalid platform: {_platform}" - return cast(CondaPlatform, _platform) + return cast("CondaPlatform", _platform) def _extract_conda_pip_dependencies( @@ -196,7 +196,7 @@ def create_conda_env_specification( # noqa: PLR0912 # other with [win]. for _platform in _platforms: pip_deps.append(dep_str) - _add_comment(pip_deps, cast(Platform, _platform)) + _add_comment(pip_deps, cast("Platform", _platform)) else: pip_deps.append(dep_str) diff --git a/unidep/_conda_lock.py b/unidep/_conda_lock.py index 07c52a84..d1e5d6d1 100644 --- a/unidep/_conda_lock.py +++ b/unidep/_conda_lock.py @@ -363,7 +363,7 @@ def _conda_lock_subpackage( yaml.representer.ignore_aliases = lambda *_: True # Disable anchors conda_lock_output = file.parent / "conda-lock.yml" metadata = { - "content_hash": {p: "unidep-is-awesome" for p in platforms}, + "content_hash": dict.fromkeys(platforms, "unidep-is-awesome"), "channels": [{"url": c, "used_env_vars": []} for c in channels], "platforms": platforms, "sources": [str(file)], diff --git a/unidep/_dependencies_parsing.py b/unidep/_dependencies_parsing.py index c217f13b..4ca8bfa1 100644 --- a/unidep/_dependencies_parsing.py +++ b/unidep/_dependencies_parsing.py @@ -230,7 +230,7 @@ def _normalize_local_dependency_use(use_value: str | None) -> LocalDependencyUse options = ", ".join(sorted(valid)) msg = f"Invalid `use` value `{use_value}`. Supported values: {options}." raise ValueError(msg) - return cast(LocalDependencyUse, normalized) + return cast("LocalDependencyUse", normalized) def get_local_dependencies(data: dict[str, Any]) -> list[LocalDependency]: diff --git a/unidep/_setuptools_integration.py b/unidep/_setuptools_integration.py index c0d7c868..d48eaa1d 100755 --- a/unidep/_setuptools_integration.py +++ b/unidep/_setuptools_integration.py @@ -223,7 +223,7 @@ class SetupVisitor(ast.NodeVisitor): def __init__(self) -> None: self.package_name = None - def visit_Call(self, node: ast.Call) -> None: # noqa: N802 + def visit_Call(self, node: ast.Call) -> None: if isinstance(node.func, ast.Name) and node.func.id == "setup": for keyword in node.keywords: if keyword.arg == "name": diff --git a/unidep/platform_definitions.py b/unidep/platform_definitions.py index a4151c31..07197124 100644 --- a/unidep/platform_definitions.py +++ b/unidep/platform_definitions.py @@ -106,7 +106,7 @@ def platforms_from_selector(selector: str) -> list[Platform]: # https://github.com/conda/conda-lock/blob/3d2bf356e2cf3f7284407423f7032189677ba9be/conda_lock/src_parser/selectors.py platforms: set[Platform] = set() for s in selector.split(): - s = cast(Selector, s) + s = cast("Selector", s) platforms |= set(PLATFORM_SELECTOR_MAP_REVERSE[s]) return sorted(platforms) diff --git a/unidep/utils.py b/unidep/utils.py index c7829612..2c2263a7 100644 --- a/unidep/utils.py +++ b/unidep/utils.py @@ -166,7 +166,7 @@ def parse_package_str(package_str: str) -> ParsedPackageStr: if selector is not None: for s in selector.split(): - validate_selector(cast(Selector, s)) + validate_selector(cast("Selector", s)) return ParsedPackageStr( package_name, @@ -222,7 +222,7 @@ def selector_from_comment(comment: str) -> str | None: return None selectors = m.group(1).strip().split() for s in selectors: - validate_selector(cast(Selector, s)) + validate_selector(cast("Selector", s)) return " ".join(selectors)