diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b768c46..a7a418c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,16 +10,16 @@ repos: - id: check-github-workflows args: ["--verbose"] - repo: https://github.com/codespell-project/codespell - rev: v2.4.2 + rev: v2.4.3 hooks: - id: codespell additional_dependencies: ["tomli>=2.4"] - repo: https://github.com/tox-dev/pyproject-fmt - rev: "v2.25.2" + rev: "v2.25.3" hooks: - id: pyproject-fmt - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.15.21" + rev: "v0.15.22" hooks: - id: ruff-format - id: ruff @@ -39,7 +39,7 @@ repos: - mdformat-gfm>=1 - mdformat-ruff>=0.1.3 - repo: https://github.com/zizmorcore/zizmor-pre-commit - rev: v1.26.1 + rev: v1.27.0 hooks: - id: zizmor - repo: meta diff --git a/docs/conf.py b/docs/conf.py index 5cd682a..3f34396 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -11,7 +11,7 @@ name = "python-discovery" version = ".".join(__version__.split(".")[:2]) release = __version__ -copyright = f"2026-{datetime.now(tz=timezone.utc).year}, {company}" # noqa: A001 +copyright = f"2026-{datetime.now(tz=timezone.utc).year}, {company}" # ruff:ignore[builtin-variable-shadowing] extensions = [ "sphinx.ext.autodoc", diff --git a/src/python_discovery/_cache.py b/src/python_discovery/_cache.py index 4e7b390..a728723 100644 --- a/src/python_discovery/_cache.py +++ b/src/python_discovery/_cache.py @@ -104,7 +104,7 @@ def remove(self) -> None: @contextmanager def locked(self) -> Generator[None]: - from filelock import FileLock # noqa: PLC0415 + from filelock import FileLock # ruff:ignore[import-outside-top-level] lock_path = self._folder / f"{self._key}.lock" lock_path.parent.mkdir(parents=True, exist_ok=True) @@ -148,10 +148,10 @@ def py_info_clear(self) -> None: class NoOpContentStore(ContentStore): """Content store that does nothing -- implements ContentStore protocol.""" - def exists(self) -> bool: # noqa: PLR6301 + def exists(self) -> bool: # ruff:ignore[no-self-use] return False - def read(self) -> dict | None: # noqa: PLR6301 + def read(self) -> dict | None: # ruff:ignore[no-self-use] return None def write(self, content: dict) -> None: @@ -161,14 +161,14 @@ def remove(self) -> None: pass @contextmanager - def locked(self) -> Generator[None]: # noqa: PLR6301 + def locked(self) -> Generator[None]: # ruff:ignore[no-self-use] yield class NoOpCache(PyInfoCache): """Cache that does nothing -- implements PyInfoCache protocol.""" - def py_info(self, path: Path) -> NoOpContentStore: # noqa: ARG002, PLR6301 + def py_info(self, path: Path) -> NoOpContentStore: # ruff:ignore[unused-method-argument, no-self-use] return NoOpContentStore() def py_info_clear(self) -> None: diff --git a/src/python_discovery/_cached_py_info.py b/src/python_discovery/_cached_py_info.py index 80bc837..ae1a1d2 100644 --- a/src/python_discovery/_cached_py_info.py +++ b/src/python_discovery/_cached_py_info.py @@ -8,14 +8,14 @@ import os import pkgutil import secrets -import subprocess # noqa: S404 +import subprocess # ruff:ignore[suspicious-subprocess-import] import sys import tempfile from collections import OrderedDict from contextlib import contextmanager from pathlib import Path from shlex import quote -from subprocess import Popen, TimeoutExpired # noqa: S404 +from subprocess import Popen, TimeoutExpired # ruff:ignore[suspicious-subprocess-import] from typing import TYPE_CHECKING, Final from ._cache import NoOpCache @@ -32,7 +32,7 @@ _LOGGER: Final[logging.Logger] = logging.getLogger(__name__) -def from_exe( # noqa: PLR0913 +def from_exe( # ruff:ignore[too-many-arguments] cls: type[PythonInfo], cache: PyInfoCache | None, exe: str, @@ -197,7 +197,7 @@ def _run_subprocess( env["PYTHONUTF8"] = "1" _LOGGER.debug("get interpreter info via cmd: %s", LogCmd(cmd)) try: - process = Popen( # noqa: S603 + process = Popen( # ruff:ignore[subprocess-without-shell-equals-true] cmd, universal_newlines=True, stdin=subprocess.PIPE, diff --git a/src/python_discovery/_discovery.py b/src/python_discovery/_discovery.py index ab5cbcf..3d82bfe 100644 --- a/src/python_discovery/_discovery.py +++ b/src/python_discovery/_discovery.py @@ -89,7 +89,7 @@ def iter_interpreters( yield from _iter_for_spec(spec_str, first_with, cache, env_map, predicate, seen) -def _iter_for_spec( # noqa: PLR0913, PLR0917 +def _iter_for_spec( # ruff:ignore[too-many-arguments, too-many-positional-arguments] spec_str: str | None, try_first_with: tuple[str, ...], cache: PyInfoCache | None, @@ -231,7 +231,7 @@ def _propose_current_and_windows( yield current_python, True if IS_WIN: # pragma: win32 cover - from ._windows import propose_interpreters as win_propose # noqa: PLC0415 + from ._windows import propose_interpreters as win_propose # ruff:ignore[import-outside-top-level] for interpreter in win_propose(spec, cache, env): if _is_new_exe(str(interpreter.executable), tested_exes): diff --git a/src/python_discovery/_py_info.py b/src/python_discovery/_py_info.py index 1098934..d26a29c 100644 --- a/src/python_discovery/_py_info.py +++ b/src/python_discovery/_py_info.py @@ -49,7 +49,7 @@ def _get_path_extensions() -> list[str]: ) -class PythonInfo: # noqa: PLR0904 +class PythonInfo: # ruff:ignore[too-many-public-methods] """Contains information for a Python interpreter.""" def __init__(self) -> None: @@ -161,7 +161,7 @@ def _get_tcl_tk_libs() -> tuple[ """Detect the tcl and tk libraries using tkinter.""" tcl_lib, tk_lib = None, None try: - import tkinter as tk # noqa: PLC0415 + import tkinter as tk # ruff:ignore[import-outside-top-level] except ImportError: pass else: @@ -177,7 +177,7 @@ def _get_tcl_tk_libs() -> tuple[ @staticmethod def _query_tk_library(tcl: tk.Tk) -> str | None: # pragma: no cover """Try to get the TK library path directly from Tcl.""" - import tkinter as tk # noqa: PLC0415 + import tkinter as tk # ruff:ignore[import-outside-top-level] try: if (tk_lib := tcl.eval("set tk_library")) and os.path.isdir(tk_lib): @@ -303,8 +303,11 @@ def _distutils_install() -> dict[str, str]: with warnings.catch_warnings(): # disable warning for PEP-632 warnings.simplefilter("ignore") try: - from distutils import dist # noqa: PLC0415 # ty: ignore[unresolved-import] - from distutils.command.install import SCHEME_KEYS # noqa: PLC0415 # ty: ignore[unresolved-import] + # ruff:ignore[import-outside-top-level] + from distutils import dist # ty: ignore[unresolved-import] + + # ruff:ignore[import-outside-top-level] + from distutils.command.install import SCHEME_KEYS # ty: ignore[unresolved-import] except ImportError: # pragma: no cover # if removed or not installed ignore return {} @@ -312,7 +315,7 @@ def _distutils_install() -> dict[str, str]: "script_args": "--no-user-cfg", }) # conf files not parsed so they do not hijack paths if hasattr(sys, "_framework"): # pragma: no cover # macOS framework builds only - sys._framework = None # noqa: SLF001 # disable macOS static paths for framework + sys._framework = None # ruff:ignore[private-member-access] # disable macOS static paths for framework with warnings.catch_warnings(): # disable warning for PEP-632 warnings.simplefilter("ignore") @@ -459,12 +462,12 @@ def clear_cache(cls, cache: PyInfoCache) -> None: :param cache: the cache store to clear. """ - from ._cached_py_info import clear # noqa: PLC0415 + from ._cached_py_info import clear # ruff:ignore[import-outside-top-level] clear(cache) cls._cache_exe_discovery.clear() - def satisfies(self, spec: PythonSpec, *, impl_must_match: bool) -> bool: # noqa: PLR0911 + def satisfies(self, spec: PythonSpec, *, impl_must_match: bool) -> bool: # ruff:ignore[too-many-return-statements] """ Check if a given specification can be satisfied by this python interpreter instance. @@ -510,7 +513,7 @@ def _satisfies_version_specifier(self, spec: PythonSpec) -> bool: return True version_info = self.version_info for specifier in spec.version_specifier: - assert specifier.version is not None # noqa: S101 + assert specifier.version is not None # ruff:ignore[assert] numeric_version = specifier.version_str for prefix in ("rc", "b", "a"): if prefix in numeric_version: @@ -520,7 +523,7 @@ def _satisfies_version_specifier(self, spec: PythonSpec) -> bool: release = ".".join(str(c) for c in [version_info.major, version_info.minor, version_info.micro][:precision]) if ( version_info.releaselevel != "final" - and (precision == 3 or specifier.version.pre_type is not None) # noqa: PLR2004 + and (precision == 3 or specifier.version.pre_type is not None) # ruff:ignore[magic-value-comparison] and (suffix := {"alpha": "a", "beta": "b", "candidate": "rc"}.get(version_info.releaselevel)) ): release = f"{release}{suffix}{version_info.serial}" @@ -573,7 +576,7 @@ def to_dict(self) -> dict[str, object]: return data @classmethod - def from_exe( # noqa: PLR0913 + def from_exe( # ruff:ignore[too-many-arguments] cls, exe: str, cache: PyInfoCache | None = None, @@ -593,7 +596,7 @@ def from_exe( # noqa: PLR0913 :param resolve_to_host: resolve through virtualenv layers to the system interpreter. :param env: environment mapping; defaults to :data:`os.environ`. """ - from ._cached_py_info import from_exe # noqa: PLC0415 + from ._cached_py_info import from_exe # ruff:ignore[import-outside-top-level] env = os.environ if env is None else env proposed = from_exe(cls, cache, exe, env=env, raise_on_error=raise_on_error, ignore_cache=ignore_cache) @@ -703,7 +706,7 @@ def discover_exe( msg = "failed to detect {} in {}".format("|".join(possible_names), os.pathsep.join(possible_folders)) raise RuntimeError(msg) - def _check_exe( # noqa: PLR0913 + def _check_exe( # ruff:ignore[too-many-arguments] self, cache: PyInfoCache | None, folder: str, @@ -797,7 +800,7 @@ def _possible_base(self) -> Generator[str, None, None]: for base in possible_base: lower = base.lower() yield lower - from ._compat import fs_is_case_sensitive # noqa: PLC0415 + from ._compat import fs_is_case_sensitive # ruff:ignore[import-outside-top-level] if fs_is_case_sensitive(): # pragma: no branch if base != lower: diff --git a/src/python_discovery/_py_spec.py b/src/python_discovery/_py_spec.py index 32beb6d..d389ad6 100644 --- a/src/python_discovery/_py_spec.py +++ b/src/python_discovery/_py_spec.py @@ -55,7 +55,7 @@ def _parse_version_parts(version: str) -> tuple[int | None, int | None, int | No raise ValueError(msg) if len(versions) == _MAX_VERSION_PARTS: return versions[0], versions[1], versions[2] - if len(versions) == 2: # noqa: PLR2004 + if len(versions) == 2: # ruff:ignore[magic-value-comparison] return versions[0], versions[1], None version_data = versions[0] major = int(str(version_data)[0]) @@ -127,7 +127,7 @@ class PythonSpec: constraints, or ``None``. """ - def __init__( # noqa: PLR0913, PLR0917 + def __init__( # ruff:ignore[too-many-arguments, too-many-positional-arguments] self, str_spec: str, implementation: str | None, @@ -233,7 +233,7 @@ def _get_required_precision(item: SimpleSpecifier) -> int | None: return len(item.version.release) return None - def satisfies(self, spec: PythonSpec) -> bool: # noqa: PLR0911 + def satisfies(self, spec: PythonSpec) -> bool: # ruff:ignore[too-many-return-statements] """ Check if this spec is compatible with the given *spec* (e.g. PEP-514 on Windows). diff --git a/src/python_discovery/_specifier.py b/src/python_discovery/_specifier.py index b2e4dc1..49bf252 100644 --- a/src/python_discovery/_specifier.py +++ b/src/python_discovery/_specifier.py @@ -92,7 +92,7 @@ def __eq__(self, other: object) -> bool: def __hash__(self) -> int: return hash((self.release, self.pre_type, self.pre_num)) - def __lt__(self, other: object) -> bool: # noqa: PLR0911 + def __lt__(self, other: object) -> bool: # ruff:ignore[too-many-return-statements] if not isinstance(other, SimpleVersion): return NotImplemented if self.release != other.release: @@ -225,7 +225,7 @@ def _check_compatible_release(self, candidate: SimpleVersion) -> bool: return False if candidate < self.version: return False - if len(self.version.release) >= 2: # noqa: PLR2004 # pragma: no branch # SimpleVersion always has 3-part release + if len(self.version.release) >= 2: # ruff:ignore[magic-value-comparison] # pragma: no branch # SimpleVersion always has 3-part release upper_parts = list(self.version.release[:-1]) upper_parts[-1] += 1 upper = SimpleVersion.from_string(".".join(str(p) for p in upper_parts)) diff --git a/src/python_discovery/_windows/_pep514.py b/src/python_discovery/_windows/_pep514.py index 474747a..51c13da 100644 --- a/src/python_discovery/_windows/_pep514.py +++ b/src/python_discovery/_windows/_pep514.py @@ -47,7 +47,7 @@ ) -def enum_keys(key: Any) -> Generator[str, None, None]: # noqa: ANN401 +def enum_keys(key: Any) -> Generator[str, None, None]: # ruff:ignore[any-type] at = 0 while True: try: @@ -57,7 +57,7 @@ def enum_keys(key: Any) -> Generator[str, None, None]: # noqa: ANN401 at += 1 -def get_value(key: Any, value_name: str | None) -> Any: # noqa: ANN401 +def get_value(key: Any, value_name: str | None) -> Any: # ruff:ignore[any-type] try: return winreg.QueryValueEx(key, value_name)[0] # ty: ignore[unresolved-attribute] except OSError: @@ -93,7 +93,7 @@ def process_set( def process_company( hive_name: str, company: str, - root_key: Any, # noqa: ANN401 + root_key: Any, # ruff:ignore[any-type] default_arch: int, ) -> Generator[_RegistrySpec, None, None]: with winreg.OpenKeyEx(root_key, company) as company_key: # ty: ignore[unresolved-attribute] @@ -103,7 +103,7 @@ def process_company( yield spec -def process_tag(hive_name: str, company: str, company_key: Any, tag: str, default_arch: int) -> _RegistrySpec | None: # noqa: ANN401 +def process_tag(hive_name: str, company: str, company_key: Any, tag: str, default_arch: int) -> _RegistrySpec | None: # ruff:ignore[any-type] with winreg.OpenKeyEx(company_key, tag) as tag_key: # ty: ignore[unresolved-attribute] version = load_version_data(hive_name, company, tag, tag_key) if version is not None: # if failed to get version bail @@ -120,7 +120,7 @@ def process_tag(hive_name: str, company: str, company_key: Any, tag: str, defaul return None -def load_exe(hive_name: str, company: str, company_key: Any, tag: str) -> tuple[str, str | None] | None: # noqa: ANN401 +def load_exe(hive_name: str, company: str, company_key: Any, tag: str) -> tuple[str, str | None] | None: # ruff:ignore[any-type] key_path = f"{hive_name}/{company}/{tag}" try: with winreg.OpenKeyEx(company_key, rf"{tag}\InstallPath") as ip_key, ip_key: # ty: ignore[unresolved-attribute] @@ -132,7 +132,7 @@ def load_exe(hive_name: str, company: str, company_key: Any, tag: str) -> tuple[ return None -def _resolve_exe(ip_key: Any, key_path: str) -> str | None: # noqa: ANN401 +def _resolve_exe(ip_key: Any, key_path: str) -> str | None: # ruff:ignore[any-type] if (exe := get_value(ip_key, "ExecutablePath")) is not None: return exe if (ip := get_value(ip_key, None)) is None: @@ -141,7 +141,7 @@ def _resolve_exe(ip_key: Any, key_path: str) -> str | None: # noqa: ANN401 return os.path.join(ip, "python.exe") -def load_arch_data(hive_name: str, company: str, tag: str, tag_key: Any, default_arch: int) -> int | None: # noqa: ANN401 +def load_arch_data(hive_name: str, company: str, tag: str, tag_key: Any, default_arch: int) -> int | None: # ruff:ignore[any-type] arch_str = get_value(tag_key, "SysArchitecture") if arch_str is not None: key_path = f"{hive_name}/{company}/{tag}/SysArchitecture" @@ -152,7 +152,7 @@ def load_arch_data(hive_name: str, company: str, tag: str, tag_key: Any, default return default_arch -def parse_arch(arch_str: Any) -> int: # noqa: ANN401 +def parse_arch(arch_str: Any) -> int: # ruff:ignore[any-type] if isinstance(arch_str, str): if match := _ARCH_RE.match(arch_str): return int(next(iter(match.groups()))) @@ -166,7 +166,7 @@ def load_version_data( hive_name: str, company: str, tag: str, - tag_key: Any, # noqa: ANN401 + tag_key: Any, # ruff:ignore[any-type] ) -> tuple[int | None, int | None, int | None] | None: for candidate, key_path in [ (get_value(tag_key, "SysVersion"), f"{hive_name}/{company}/{tag}/SysVersion"), @@ -180,7 +180,7 @@ def load_version_data( return None -def parse_version(version_str: Any) -> tuple[int | None, int | None, int | None]: # noqa: ANN401 +def parse_version(version_str: Any) -> tuple[int | None, int | None, int | None]: # ruff:ignore[any-type] if isinstance(version_str, str): if match := _VERSION_RE.match(version_str): g1, g2, g3 = match.groups() @@ -195,7 +195,7 @@ def parse_version(version_str: Any) -> tuple[int | None, int | None, int | None] raise ValueError(error) -def load_threaded(hive_name: str, company: str, tag: str, tag_key: Any) -> bool: # noqa: ANN401 +def load_threaded(hive_name: str, company: str, tag: str, tag_key: Any) -> bool: # ruff:ignore[any-type] display_name = get_value(tag_key, "DisplayName") if display_name is not None: if isinstance(display_name, str): diff --git a/tasks/release.py b/tasks/release.py index 92e0a5d..9306ae9 100644 --- a/tasks/release.py +++ b/tasks/release.py @@ -41,7 +41,7 @@ def main(version_str: str) -> None: def create_release_branch(repo: Repo, version: Version) -> tuple[Remote, Head]: - print("create release branch from upstream main") # noqa: T201 + print("create release branch from upstream main") # ruff:ignore[print] upstream = get_upstream(repo) upstream.fetch() branch_name = f"release-{version}" @@ -63,71 +63,71 @@ def get_upstream(repo: Repo) -> Remote: def push_release(repo: Repo, upstream: Remote, release_branch: Head, version: Version) -> tuple[bool, bool, bool]: release_commit = release_changelog(repo, version) tag = tag_release_commit(release_commit, repo, version) - print("push release commit") # noqa: T201 + print("push release commit") # ruff:ignore[print] repo.git.push(upstream.name, f"{release_branch}:main", "-f") - print("push release tag") # noqa: T201 + print("push release tag") # ruff:ignore[print] repo.git.push(upstream.name, tag, "-f") create_github_release(version) return True, True, True def release_changelog(repo: Repo, version: Version) -> Commit: - print("generate release commit") # noqa: T201 - check_call(["towncrier", "build", "--yes", "--version", version.public], cwd=str(ROOT_SRC_DIR)) # noqa: S607 - print("format changelog with pre-commit") # noqa: T201 + print("generate release commit") # ruff:ignore[print] + check_call(["towncrier", "build", "--yes", "--version", version.public], cwd=str(ROOT_SRC_DIR)) # ruff:ignore[start-process-with-partial-path] + print("format changelog with pre-commit") # ruff:ignore[print] changelog_path = ROOT_SRC_DIR / "docs" / "changelog.rst" try: - check_call(["pre-commit", "run", "--files", str(changelog_path)], cwd=str(ROOT_SRC_DIR)) # noqa: S607 + check_call(["pre-commit", "run", "--files", str(changelog_path)], cwd=str(ROOT_SRC_DIR)) # ruff:ignore[start-process-with-partial-path] except CalledProcessError: - print("pre-commit made formatting changes, staging them") # noqa: T201 + print("pre-commit made formatting changes, staging them") # ruff:ignore[print] repo.index.add([str(changelog_path)]) return repo.index.commit(f"release {version}") def tag_release_commit(release_commit: Commit, repo: Repo, version: Version) -> TagReference: - print("tag release commit") # noqa: T201 + print("tag release commit") # ruff:ignore[print] version_str = str(version) if version_str in {tag.name for tag in repo.tags}: - print(f"delete existing tag {version_str}") # noqa: T201 + print(f"delete existing tag {version_str}") # ruff:ignore[print] repo.delete_tag(repo.tags[version_str]) - print(f"create tag {version_str}") # noqa: T201 + print(f"create tag {version_str}") # ruff:ignore[print] return repo.create_tag(version_str, ref=release_commit.hexsha, force=True) def create_github_release(version: Version) -> None: - print("create github release") # noqa: T201 + print("create github release") # ruff:ignore[print] version_str = str(version) try: result = run( - ["gh", "release", "create", version_str, "--title", f"v{version_str}", "--generate-notes"], # noqa: S607 + ["gh", "release", "create", version_str, "--title", f"v{version_str}", "--generate-notes"], # ruff:ignore[start-process-with-partial-path] cwd=str(ROOT_SRC_DIR), capture_output=True, text=True, check=True, ) if result.stdout: - print(result.stdout) # noqa: T201 + print(result.stdout) # ruff:ignore[print] except CalledProcessError as e: - print(f"gh release create failed with exit code {e.returncode}") # noqa: T201 + print(f"gh release create failed with exit code {e.returncode}") # ruff:ignore[print] if e.stdout: - print(f"stdout: {e.stdout}") # noqa: T201 + print(f"stdout: {e.stdout}") # ruff:ignore[print] if e.stderr: - print(f"stderr: {e.stderr}") # noqa: T201 + print(f"stderr: {e.stderr}") # ruff:ignore[print] raise def finalize_release(repo: Repo, upstream: Remote, release_branch: Head) -> None: - print("checkout main to new release and delete release branch") # noqa: T201 + print("checkout main to new release and delete release branch") # ruff:ignore[print] repo.heads.main.checkout() repo.delete_head(release_branch, force=True) - print("delete remote release branch") # noqa: T201 + print("delete remote release branch") # ruff:ignore[print] repo.git.push(upstream.name, f":{release_branch}", "--no-verify") upstream.fetch() repo.git.reset("--hard", f"{upstream.name}/main") - print("All done!") # noqa: T201 + print("All done!") # ruff:ignore[print] -def cleanup_failed_release( # noqa: PLR0913 +def cleanup_failed_release( # ruff:ignore[too-many-arguments] repo: Repo, upstream: Remote, version: Version, @@ -138,30 +138,30 @@ def cleanup_failed_release( # noqa: PLR0913 tag_pushed: bool, main_pushed: bool, ) -> None: - print("Release failed! Cleaning up...") # noqa: T201 + print("Release failed! Cleaning up...") # ruff:ignore[print] if release_created: - print(f"Deleting GitHub release {version}") # noqa: T201 + print(f"Deleting GitHub release {version}") # ruff:ignore[print] try: - check_call(["gh", "release", "delete", str(version), "--yes"], cwd=str(ROOT_SRC_DIR)) # noqa: S607 - except Exception as cleanup_error: # noqa: BLE001 - print(f"Warning: Failed to delete GitHub release: {cleanup_error}") # noqa: T201 + check_call(["gh", "release", "delete", str(version), "--yes"], cwd=str(ROOT_SRC_DIR)) # ruff:ignore[start-process-with-partial-path] + except Exception as cleanup_error: # ruff:ignore[blind-except] + print(f"Warning: Failed to delete GitHub release: {cleanup_error}") # ruff:ignore[print] if tag_pushed: - print(f"Deleting remote tag {version}") # noqa: T201 + print(f"Deleting remote tag {version}") # ruff:ignore[print] try: repo.git.push(upstream.name, f":refs/tags/{version}", "--no-verify") - except Exception as cleanup_error: # noqa: BLE001 - print(f"Warning: Failed to delete remote tag: {cleanup_error}") # noqa: T201 + except Exception as cleanup_error: # ruff:ignore[blind-except] + print(f"Warning: Failed to delete remote tag: {cleanup_error}") # ruff:ignore[print] if main_pushed: - print(f"Reverting main to {original_main_sha[:8]}") # noqa: T201 + print(f"Reverting main to {original_main_sha[:8]}") # ruff:ignore[print] try: repo.git.push(upstream.name, f"{original_main_sha}:main", "-f", "--no-verify") - except Exception as cleanup_error: # noqa: BLE001 - print(f"Warning: Failed to revert main: {cleanup_error}") # noqa: T201 - print("Deleting remote release branch") # noqa: T201 + except Exception as cleanup_error: # ruff:ignore[blind-except] + print(f"Warning: Failed to revert main: {cleanup_error}") # ruff:ignore[print] + print("Deleting remote release branch") # ruff:ignore[print] try: repo.git.push(upstream.name, f":{release_branch}", "--no-verify") - except Exception as cleanup_error: # noqa: BLE001 - print(f"Warning: Failed to delete remote branch: {cleanup_error}") # noqa: T201 + except Exception as cleanup_error: # ruff:ignore[blind-except] + print(f"Warning: Failed to delete remote branch: {cleanup_error}") # ruff:ignore[print] if __name__ == "__main__": diff --git a/tests/test_specifier.py b/tests/test_specifier.py index 00d19a9..6091452 100644 --- a/tests/test_specifier.py +++ b/tests/test_specifier.py @@ -44,7 +44,7 @@ def test_version_eq_different() -> None: def test_version_eq_not_implemented() -> None: - result = SimpleVersion.from_string("3.11").__eq__("3.11") # noqa: PLC2801 + result = SimpleVersion.from_string("3.11").__eq__("3.11") # ruff:ignore[unnecessary-dunder-call] assert result is NotImplemented @@ -69,7 +69,7 @@ def test_version_lt(left: str, right: str, expected: bool) -> None: def test_version_lt_not_implemented() -> None: - result = SimpleVersion.from_string("3.11").__lt__("3.12") # noqa: PLC2801 + result = SimpleVersion.from_string("3.11").__lt__("3.12") # ruff:ignore[unnecessary-dunder-call] assert result is NotImplemented @@ -83,7 +83,7 @@ def test_version_gt() -> None: def test_version_gt_not_implemented() -> None: - result = SimpleVersion.from_string("3.11").__gt__("3.11") # noqa: PLC2801 + result = SimpleVersion.from_string("3.11").__gt__("3.11") # ruff:ignore[unnecessary-dunder-call] assert result is NotImplemented @@ -198,7 +198,7 @@ def test_specifier_eq() -> None: def test_specifier_eq_not_implemented() -> None: - result = SimpleSpecifier.from_string(">=3.12").__eq__(">=3.12") # noqa: PLC2801 + result = SimpleSpecifier.from_string(">=3.12").__eq__(">=3.12") # ruff:ignore[unnecessary-dunder-call] assert result is NotImplemented @@ -262,7 +262,7 @@ def test_specifier_set_eq() -> None: def test_specifier_set_eq_not_implemented() -> None: - result = SimpleSpecifierSet.from_string(">=3.12").__eq__(">=3.12") # noqa: PLC2801 + result = SimpleSpecifierSet.from_string(">=3.12").__eq__(">=3.12") # ruff:ignore[unnecessary-dunder-call] assert result is NotImplemented diff --git a/tests/windows/conftest.py b/tests/windows/conftest.py index 25d5a35..203ca4b 100644 --- a/tests/windows/conftest.py +++ b/tests/windows/conftest.py @@ -42,7 +42,7 @@ def _load_registry_data( loc: dict[str, object] = {} glob: dict[str, object] = {"winreg": winreg} mock_value_str = (Path(__file__).parent / "winreg_mock_values.py").read_text(encoding="utf-8") - exec(mock_value_str, glob, loc) # noqa: S102 + exec(mock_value_str, glob, loc) # ruff:ignore[exec-builtin] return loc["enum_collect"], loc["value_collect"], loc["key_open"], loc["hive_open"] # type: ignore[return-value]