diff --git a/src/pkgmgr/__init__.py b/src/pkgmgr/__init__.py index 54e3c11..427934d 100644 --- a/src/pkgmgr/__init__.py +++ b/src/pkgmgr/__init__.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ Top-level pkgmgr package. diff --git a/src/pkgmgr/actions/__init__.py b/src/pkgmgr/actions/__init__.py index a1e49fe..f50bb69 100644 --- a/src/pkgmgr/actions/__init__.py +++ b/src/pkgmgr/actions/__init__.py @@ -1,6 +1,6 @@ from __future__ import annotations # expose subpackages for patch() / resolve_name() friendliness -from . import release as release # noqa: F401 +from . import release as release __all__ = ["release"] diff --git a/src/pkgmgr/actions/archive/discovery.py b/src/pkgmgr/actions/archive/discovery.py index dc5cf40..de7300d 100644 --- a/src/pkgmgr/actions/archive/discovery.py +++ b/src/pkgmgr/actions/archive/discovery.py @@ -3,8 +3,8 @@ from __future__ import annotations import re +from collections.abc import Iterable from pathlib import Path -from typing import Iterable DEFAULT_FILENAME_PATTERN = re.compile(r"^\d{3}-[^/]+\.md$") TEMPLATE_FILENAME = "000-template.md" diff --git a/src/pkgmgr/actions/branch/__init__.py b/src/pkgmgr/actions/branch/__init__.py index 200cab3..309a14d 100644 --- a/src/pkgmgr/actions/branch/__init__.py +++ b/src/pkgmgr/actions/branch/__init__.py @@ -1,14 +1,13 @@ -# -*- coding: utf-8 -*- """ Public API for branch actions. """ -from .open_branch import open_branch from .close_branch import close_branch from .drop_branch import drop_branch +from .open_branch import open_branch __all__ = [ - "open_branch", "close_branch", "drop_branch", + "open_branch", ] diff --git a/src/pkgmgr/actions/branch/close_branch.py b/src/pkgmgr/actions/branch/close_branch.py index 86c5a82..d9b8b39 100644 --- a/src/pkgmgr/actions/branch/close_branch.py +++ b/src/pkgmgr/actions/branch/close_branch.py @@ -2,8 +2,6 @@ from __future__ import annotations from typing import Optional -from pkgmgr.core.git.errors import GitRunError -from pkgmgr.core.git.queries import get_current_branch from pkgmgr.core.git.commands import ( GitDeleteRemoteBranchError, checkout, @@ -14,8 +12,8 @@ from pkgmgr.core.git.commands import ( pull, push, ) - -from pkgmgr.core.git.queries import resolve_base_branch +from pkgmgr.core.git.errors import GitRunError +from pkgmgr.core.git.queries import get_current_branch, resolve_base_branch def close_branch( diff --git a/src/pkgmgr/actions/branch/drop_branch.py b/src/pkgmgr/actions/branch/drop_branch.py index e50873a..9010233 100644 --- a/src/pkgmgr/actions/branch/drop_branch.py +++ b/src/pkgmgr/actions/branch/drop_branch.py @@ -2,15 +2,13 @@ from __future__ import annotations from typing import Optional -from pkgmgr.core.git.errors import GitRunError -from pkgmgr.core.git.queries import get_current_branch from pkgmgr.core.git.commands import ( GitDeleteRemoteBranchError, delete_local_branch, delete_remote_branch, ) - -from pkgmgr.core.git.queries import resolve_base_branch +from pkgmgr.core.git.errors import GitRunError +from pkgmgr.core.git.queries import get_current_branch, resolve_base_branch def drop_branch( diff --git a/src/pkgmgr/actions/changelog/__init__.py b/src/pkgmgr/actions/changelog/__init__.py index d3557cc..88cb2a5 100644 --- a/src/pkgmgr/actions/changelog/__init__.py +++ b/src/pkgmgr/actions/changelog/__init__.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ Helpers to generate changelog information from Git history. @@ -10,8 +9,8 @@ from __future__ import annotations from typing import Optional from pkgmgr.core.git.queries import ( - get_changelog, GitChangelogQueryError, + get_changelog, ) diff --git a/src/pkgmgr/actions/code_scanning/__init__.py b/src/pkgmgr/actions/code_scanning/__init__.py index 814a4b6..c2cdc0c 100644 --- a/src/pkgmgr/actions/code_scanning/__init__.py +++ b/src/pkgmgr/actions/code_scanning/__init__.py @@ -30,7 +30,7 @@ class CodeScanningResult: files: List[str] = field(default_factory=list) -def _gh(args: List[str]) -> "subprocess.CompletedProcess[str]": +def _gh(args: List[str]) -> subprocess.CompletedProcess[str]: return subprocess.run(["gh", *args], capture_output=True, text=True) diff --git a/src/pkgmgr/actions/config/add.py b/src/pkgmgr/actions/config/add.py index dd4a5c9..f4962ae 100644 --- a/src/pkgmgr/actions/config/add.py +++ b/src/pkgmgr/actions/config/add.py @@ -1,5 +1,7 @@ -import yaml import os + +import yaml + from pkgmgr.core.config.save import save_user_config diff --git a/src/pkgmgr/actions/config/init.py b/src/pkgmgr/actions/config/init.py index 9c9a6f9..2c6a158 100644 --- a/src/pkgmgr/actions/config/init.py +++ b/src/pkgmgr/actions/config/init.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ Initialize user configuration by scanning the repositories base directory. @@ -55,7 +54,7 @@ def config_init( print("[INIT] Scanning repository base directory:") print(f" {repositories_base_dir}") - print("") + print() if not os.path.isdir(repositories_base_dir): print(f"[ERROR] Base directory does not exist: {repositories_base_dir}") @@ -153,7 +152,7 @@ def config_init( new_entries.append(entry) - print("") # blank line between accounts + print() # blank line between accounts # ------------------------------------------------------------ # Summary diff --git a/src/pkgmgr/actions/config/show.py b/src/pkgmgr/actions/config/show.py index e973eeb..dcbee75 100644 --- a/src/pkgmgr/actions/config/show.py +++ b/src/pkgmgr/actions/config/show.py @@ -1,4 +1,5 @@ import yaml + from pkgmgr.core.config.load import load_config diff --git a/src/pkgmgr/actions/install/__init__.py b/src/pkgmgr/actions/install/__init__.py index 56ecc71..dac0267 100644 --- a/src/pkgmgr/actions/install/__init__.py +++ b/src/pkgmgr/actions/install/__init__.py @@ -18,24 +18,24 @@ from __future__ import annotations import os from typing import Any, Dict, List, Optional, Tuple -from pkgmgr.core.repository.identifier import get_repo_identifier -from pkgmgr.core.repository.dir import get_repo_dir -from pkgmgr.core.repository.verify import verify_repository -from pkgmgr.actions.repository.clone import clone_repos from pkgmgr.actions.install.context import RepoContext +from pkgmgr.actions.install.installers.makefile import ( + MakefileInstaller, +) +from pkgmgr.actions.install.installers.nix import ( + NixFlakeInstaller, +) from pkgmgr.actions.install.installers.os_packages import ( ArchPkgbuildInstaller, DebianControlInstaller, RpmSpecInstaller, ) -from pkgmgr.actions.install.installers.nix import ( - NixFlakeInstaller, -) from pkgmgr.actions.install.installers.python import PythonInstaller -from pkgmgr.actions.install.installers.makefile import ( - MakefileInstaller, -) from pkgmgr.actions.install.pipeline import InstallationPipeline +from pkgmgr.actions.repository.clone import clone_repos +from pkgmgr.core.repository.dir import get_repo_dir +from pkgmgr.core.repository.identifier import get_repo_identifier +from pkgmgr.core.repository.verify import verify_repository Repository = Dict[str, Any] diff --git a/src/pkgmgr/actions/install/capabilities.py b/src/pkgmgr/actions/install/capabilities.py index 1a0a90f..1770af7 100644 --- a/src/pkgmgr/actions/install/capabilities.py +++ b/src/pkgmgr/actions/install/capabilities.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ Capability detection for pkgmgr. @@ -35,7 +34,8 @@ from __future__ import annotations import glob import os from abc import ABC, abstractmethod -from typing import Iterable, TYPE_CHECKING, Optional +from collections.abc import Iterable +from typing import TYPE_CHECKING, Optional if TYPE_CHECKING: from pkgmgr.actions.install.context import RepoContext @@ -100,7 +100,7 @@ class CapabilityMatcher(ABC): raise NotImplementedError @abstractmethod - def is_provided(self, ctx: "RepoContext", layer: str) -> bool: + def is_provided(self, ctx: RepoContext, layer: str) -> bool: """ Return True if this capability is actually provided by the given layer for this repository. @@ -133,7 +133,7 @@ class PythonRuntimeCapability(CapabilityMatcher): # OS packages may wrap Python builds, but must explicitly prove it return layer in {"python", "nix", "os-packages"} - def is_provided(self, ctx: "RepoContext", layer: str) -> bool: + def is_provided(self, ctx: RepoContext, layer: str) -> bool: repo_dir = ctx.repo_dir if layer == "python": @@ -208,7 +208,7 @@ class MakeInstallCapability(CapabilityMatcher): def applies_to_layer(self, layer: str) -> bool: return layer in {"makefile", "python", "nix", "os-packages"} - def is_provided(self, ctx: "RepoContext", layer: str) -> bool: + def is_provided(self, ctx: RepoContext, layer: str) -> bool: repo_dir = ctx.repo_dir if layer == "makefile": @@ -274,7 +274,7 @@ class NixFlakeCapability(CapabilityMatcher): # Only Nix itself and OS packages that explicitly wrap Nix return layer in {"nix", "os-packages"} - def is_provided(self, ctx: "RepoContext", layer: str) -> bool: + def is_provided(self, ctx: RepoContext, layer: str) -> bool: repo_dir = ctx.repo_dir if layer == "nix": @@ -328,7 +328,7 @@ LAYER_ORDER: list[str] = [ def detect_capabilities( - ctx: "RepoContext", + ctx: RepoContext, layers: Iterable[str], ) -> dict[str, set[str]]: """ @@ -359,7 +359,7 @@ def detect_capabilities( def resolve_effective_capabilities( - ctx: "RepoContext", + ctx: RepoContext, layers: Optional[Iterable[str]] = None, ) -> dict[str, set[str]]: """ diff --git a/src/pkgmgr/actions/install/installers/__init__.py b/src/pkgmgr/actions/install/installers/__init__.py index c41a38e..9694cbf 100644 --- a/src/pkgmgr/actions/install/installers/__init__.py +++ b/src/pkgmgr/actions/install/installers/__init__.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ Installer package for pkgmgr. @@ -9,15 +8,17 @@ pkgmgr.actions.install.installers. """ from pkgmgr.actions.install.installers.base import BaseInstaller # noqa: F401 -from pkgmgr.actions.install.installers.nix import NixFlakeInstaller # noqa: F401 -from pkgmgr.actions.install.installers.python import PythonInstaller # noqa: F401 from pkgmgr.actions.install.installers.makefile import MakefileInstaller # noqa: F401 +from pkgmgr.actions.install.installers.nix import NixFlakeInstaller # noqa: F401 # OS-specific installers from pkgmgr.actions.install.installers.os_packages.arch_pkgbuild import ( ArchPkgbuildInstaller as ArchPkgbuildInstaller, -) # noqa: F401 +) from pkgmgr.actions.install.installers.os_packages.debian_control import ( DebianControlInstaller as DebianControlInstaller, -) # noqa: F401 -from pkgmgr.actions.install.installers.os_packages.rpm_spec import RpmSpecInstaller # noqa: F401 +) +from pkgmgr.actions.install.installers.os_packages.rpm_spec import ( + RpmSpecInstaller, # noqa: F401 +) +from pkgmgr.actions.install.installers.python import PythonInstaller # noqa: F401 diff --git a/src/pkgmgr/actions/install/installers/base.py b/src/pkgmgr/actions/install/installers/base.py index 851f04c..28f1468 100644 --- a/src/pkgmgr/actions/install/installers/base.py +++ b/src/pkgmgr/actions/install/installers/base.py @@ -1,15 +1,14 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ Base interface for all installer components in the pkgmgr installation pipeline. """ from abc import ABC, abstractmethod -from typing import Set, Optional +from typing import Optional, Set -from pkgmgr.actions.install.context import RepoContext from pkgmgr.actions.install.capabilities import CAPABILITY_MATCHERS +from pkgmgr.actions.install.context import RepoContext class BaseInstaller(ABC): diff --git a/src/pkgmgr/actions/install/installers/nix/conflicts.py b/src/pkgmgr/actions/install/installers/nix/conflicts.py index 2967b6e..65014ee 100644 --- a/src/pkgmgr/actions/install/installers/nix/conflicts.py +++ b/src/pkgmgr/actions/install/installers/nix/conflicts.py @@ -33,7 +33,7 @@ class NixConflictResolver: def resolve( self, - ctx: "RepoContext", + ctx: RepoContext, install_cmd: str, stdout: str, stderr: str, diff --git a/src/pkgmgr/actions/install/installers/nix/installer.py b/src/pkgmgr/actions/install/installers/nix/installer.py index 3c53301..79c207e 100644 --- a/src/pkgmgr/actions/install/installers/nix/installer.py +++ b/src/pkgmgr/actions/install/installers/nix/installer.py @@ -28,7 +28,7 @@ class NixFlakeInstaller(BaseInstaller): # Newer nix rejects numeric indices; we learn this at runtime and cache the decision. self._indices_supported: bool | None = None - def supports(self, ctx: "RepoContext") -> bool: + def supports(self, ctx: RepoContext) -> bool: if os.environ.get("PKGMGR_DISABLE_NIX_FLAKE_INSTALLER") == "1": if not ctx.quiet: print( @@ -42,13 +42,13 @@ class NixFlakeInstaller(BaseInstaller): return os.path.exists(os.path.join(ctx.repo_dir, self.FLAKE_FILE)) - def _profile_outputs(self, ctx: "RepoContext") -> List[Tuple[str, bool]]: + def _profile_outputs(self, ctx: RepoContext) -> List[Tuple[str, bool]]: # (output_name, allow_failure) if ctx.identifier in {"pkgmgr", "package-manager"}: return [("pkgmgr", False), ("default", True)] return [("default", False)] - def run(self, ctx: "RepoContext") -> None: + def run(self, ctx: RepoContext) -> None: if not self.supports(ctx): return @@ -68,7 +68,7 @@ class NixFlakeInstaller(BaseInstaller): else: self._install_only(ctx, output, allow_failure) - def _installable(self, ctx: "RepoContext", output: str) -> str: + def _installable(self, ctx: RepoContext, output: str) -> str: return f"{ctx.repo_dir}#{output}" # --------------------------------------------------------------------- @@ -76,7 +76,7 @@ class NixFlakeInstaller(BaseInstaller): # --------------------------------------------------------------------- def _install_only( - self, ctx: "RepoContext", output: str, allow_failure: bool + self, ctx: RepoContext, output: str, allow_failure: bool ) -> None: install_cmd = f"nix profile install {self._installable(ctx, output)}" @@ -162,7 +162,7 @@ class NixFlakeInstaller(BaseInstaller): # --------------------------------------------------------------------- def _force_upgrade_output( - self, ctx: "RepoContext", output: str, allow_failure: bool + self, ctx: RepoContext, output: str, allow_failure: bool ) -> None: # Prefer token path if indices unsupported (new nix) if self._indices_supported is False: @@ -215,7 +215,7 @@ class NixFlakeInstaller(BaseInstaller): s = (stderr or "").lower() return "no longer supports indices" in s or "does not support indices" in s - def _upgrade_index(self, ctx: "RepoContext", idx: int) -> bool: + def _upgrade_index(self, ctx: RepoContext, idx: int) -> bool: cmd = f"nix profile upgrade --refresh {idx}" res = self._runner.run(ctx, cmd, allow_failure=True) @@ -228,7 +228,7 @@ class NixFlakeInstaller(BaseInstaller): return res.returncode == 0 - def _remove_index(self, ctx: "RepoContext", idx: int) -> None: + def _remove_index(self, ctx: RepoContext, idx: int) -> None: res = self._runner.run(ctx, f"nix profile remove {idx}", allow_failure=True) if self._stderr_says_indices_unsupported(getattr(res, "stderr", "")): @@ -237,7 +237,7 @@ class NixFlakeInstaller(BaseInstaller): if self._indices_supported is None: self._indices_supported = True - def _remove_tokens_for_output(self, ctx: "RepoContext", output: str) -> None: + def _remove_tokens_for_output(self, ctx: RepoContext, output: str) -> None: tokens = self._profile.find_remove_tokens_for_output(ctx, self._runner, output) if not tokens: return diff --git a/src/pkgmgr/actions/install/installers/nix/profile/__init__.py b/src/pkgmgr/actions/install/installers/nix/profile/__init__.py index 1b221f3..43d5c40 100644 --- a/src/pkgmgr/actions/install/installers/nix/profile/__init__.py +++ b/src/pkgmgr/actions/install/installers/nix/profile/__init__.py @@ -1,4 +1,4 @@ from .inspector import NixProfileInspector from .models import NixProfileEntry -__all__ = ["NixProfileInspector", "NixProfileEntry"] +__all__ = ["NixProfileEntry", "NixProfileInspector"] diff --git a/src/pkgmgr/actions/install/installers/nix/profile/inspector.py b/src/pkgmgr/actions/install/installers/nix/profile/inspector.py index 1725fbf..c14163a 100644 --- a/src/pkgmgr/actions/install/installers/nix/profile/inspector.py +++ b/src/pkgmgr/actions/install/installers/nix/profile/inspector.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Any, List, TYPE_CHECKING +from typing import TYPE_CHECKING, Any, List from .matcher import ( entry_matches_output, @@ -29,7 +29,7 @@ class NixProfileInspector: - find_remove_tokens_for_store_prefixes() """ - def list_json(self, ctx: "RepoContext", runner: "CommandRunner") -> dict[str, Any]: + def list_json(self, ctx: RepoContext, runner: CommandRunner) -> dict[str, Any]: res = runner.run(ctx, "nix profile list --json", allow_failure=False) raw = extract_stdout_text(res) return parse_profile_list_json(raw) @@ -40,8 +40,8 @@ class NixProfileInspector: def find_installed_indices_for_output( self, - ctx: "RepoContext", - runner: "CommandRunner", + ctx: RepoContext, + runner: CommandRunner, output: str, ) -> List[int]: data = self.list_json(ctx, runner) @@ -58,8 +58,8 @@ class NixProfileInspector: def find_indices_by_store_path( self, - ctx: "RepoContext", - runner: "CommandRunner", + ctx: RepoContext, + runner: CommandRunner, store_path: str, ) -> List[int]: needle = (store_path or "").strip() @@ -84,8 +84,8 @@ class NixProfileInspector: def find_remove_tokens_for_output( self, - ctx: "RepoContext", - runner: "CommandRunner", + ctx: RepoContext, + runner: CommandRunner, output: str, ) -> List[str]: """ @@ -128,8 +128,8 @@ class NixProfileInspector: def find_remove_tokens_for_store_prefixes( self, - ctx: "RepoContext", - runner: "CommandRunner", + ctx: RepoContext, + runner: CommandRunner, prefixes: List[str], ) -> List[str]: """ diff --git a/src/pkgmgr/actions/install/installers/nix/profile/normalizer.py b/src/pkgmgr/actions/install/installers/nix/profile/normalizer.py index 12afe9c..29674ad 100644 --- a/src/pkgmgr/actions/install/installers/nix/profile/normalizer.py +++ b/src/pkgmgr/actions/install/installers/nix/profile/normalizer.py @@ -1,7 +1,8 @@ from __future__ import annotations import re -from typing import Any, Dict, Iterable, List, Optional +from collections.abc import Iterable +from typing import Any, Dict, List, Optional from .models import NixProfileEntry diff --git a/src/pkgmgr/actions/install/installers/nix/profile_list.py b/src/pkgmgr/actions/install/installers/nix/profile_list.py index 34e1b03..302af7a 100644 --- a/src/pkgmgr/actions/install/installers/nix/profile_list.py +++ b/src/pkgmgr/actions/install/installers/nix/profile_list.py @@ -19,7 +19,7 @@ class NixProfileListReader: m = re.match(r"^(/nix/store/[0-9a-z]{32}-[^/ \t]+)", raw) return m.group(1) if m else raw - def entries(self, ctx: "RepoContext") -> List[Tuple[int, str]]: + def entries(self, ctx: RepoContext) -> List[Tuple[int, str]]: res = self._runner.run(ctx, "nix profile list", allow_failure=True) if res.returncode != 0: return [] @@ -49,7 +49,7 @@ class NixProfileListReader: return uniq def indices_matching_store_prefixes( - self, ctx: "RepoContext", prefixes: List[str] + self, ctx: RepoContext, prefixes: List[str] ) -> List[int]: prefixes = [self._store_prefix(p) for p in prefixes if p] prefixes = [p for p in prefixes if p] diff --git a/src/pkgmgr/actions/install/installers/nix/retry.py b/src/pkgmgr/actions/install/installers/nix/retry.py index 3f2a663..0e27201 100644 --- a/src/pkgmgr/actions/install/installers/nix/retry.py +++ b/src/pkgmgr/actions/install/installers/nix/retry.py @@ -2,13 +2,15 @@ from __future__ import annotations import random import time +from collections.abc import Iterable from dataclasses import dataclass -from typing import Iterable, TYPE_CHECKING +from typing import TYPE_CHECKING from .types import RunResult if TYPE_CHECKING: from pkgmgr.actions.install.context import RepoContext + from .runner import CommandRunner @@ -31,8 +33,8 @@ class GitHubRateLimitRetry: def run_with_retry( self, - ctx: "RepoContext", - runner: "CommandRunner", + ctx: RepoContext, + runner: CommandRunner, install_cmd: str, ) -> RunResult: quiet = bool(getattr(ctx, "quiet", False)) diff --git a/src/pkgmgr/actions/install/installers/nix/runner.py b/src/pkgmgr/actions/install/installers/nix/runner.py index c805489..3638ff8 100644 --- a/src/pkgmgr/actions/install/installers/nix/runner.py +++ b/src/pkgmgr/actions/install/installers/nix/runner.py @@ -1,7 +1,6 @@ from __future__ import annotations import subprocess - from typing import TYPE_CHECKING from .types import RunResult @@ -16,7 +15,7 @@ class CommandRunner: Supports preview mode and compact failure output logging. """ - def run(self, ctx: "RepoContext", cmd: str, allow_failure: bool) -> RunResult: + def run(self, ctx: RepoContext, cmd: str, allow_failure: bool) -> RunResult: repo_dir = getattr(ctx, "repo_dir", None) or getattr(ctx, "repo_path", None) preview = bool(getattr(ctx, "preview", False)) quiet = bool(getattr(ctx, "quiet", False)) diff --git a/src/pkgmgr/actions/install/installers/os_packages/debian_control.py b/src/pkgmgr/actions/install/installers/os_packages/debian_control.py index bcdf935..ea1eeaf 100644 --- a/src/pkgmgr/actions/install/installers/os_packages/debian_control.py +++ b/src/pkgmgr/actions/install/installers/os_packages/debian_control.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ Installer for Debian/Ubuntu packages defined via debian/control. diff --git a/src/pkgmgr/actions/install/installers/os_packages/rpm_spec.py b/src/pkgmgr/actions/install/installers/os_packages/rpm_spec.py index e17b75a..00248c7 100644 --- a/src/pkgmgr/actions/install/installers/os_packages/rpm_spec.py +++ b/src/pkgmgr/actions/install/installers/os_packages/rpm_spec.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ Installer for RPM-based packages defined in *.spec files. @@ -202,9 +201,7 @@ class RpmSpecInstaller(BaseInstaller): if shutil.which("dnf") is not None: cmd = f"sudo dnf builddep -y {spec_basename}" - elif shutil.which("yum-builddep") is not None: - cmd = f"sudo yum-builddep -y {spec_basename}" - elif shutil.which("yum") is not None: + elif shutil.which("yum-builddep") is not None or shutil.which("yum") is not None: cmd = f"sudo yum-builddep -y {spec_basename}" else: print( diff --git a/src/pkgmgr/actions/install/installers/python.py b/src/pkgmgr/actions/install/installers/python.py index 45f1e37..33356ef 100644 --- a/src/pkgmgr/actions/install/installers/python.py +++ b/src/pkgmgr/actions/install/installers/python.py @@ -4,8 +4,8 @@ from __future__ import annotations import os import sys -from pkgmgr.actions.install.installers.base import BaseInstaller from pkgmgr.actions.install.context import RepoContext +from pkgmgr.actions.install.installers.base import BaseInstaller from pkgmgr.core.command.run import run_command diff --git a/src/pkgmgr/actions/install/layers.py b/src/pkgmgr/actions/install/layers.py index d0d228a..f36d081 100644 --- a/src/pkgmgr/actions/install/layers.py +++ b/src/pkgmgr/actions/install/layers.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ CLI layer model for the pkgmgr installation pipeline. diff --git a/src/pkgmgr/actions/install/pipeline.py b/src/pkgmgr/actions/install/pipeline.py index a9b18f3..f32f37f 100644 --- a/src/pkgmgr/actions/install/pipeline.py +++ b/src/pkgmgr/actions/install/pipeline.py @@ -8,8 +8,9 @@ Installation pipeline orchestration for repositories. from __future__ import annotations +from collections.abc import Sequence from dataclasses import dataclass -from typing import Optional, Sequence, Set +from typing import Optional, Set from pkgmgr.actions.install.context import RepoContext from pkgmgr.actions.install.installers.base import BaseInstaller diff --git a/src/pkgmgr/actions/mirror/__init__.py b/src/pkgmgr/actions/mirror/__init__.py index d77f419..ae473e1 100644 --- a/src/pkgmgr/actions/mirror/__init__.py +++ b/src/pkgmgr/actions/mirror/__init__.py @@ -9,19 +9,20 @@ Public API: """ from __future__ import annotations -from .types import Repository, MirrorMap -from .list_cmd import list_mirrors + from .diff_cmd import diff_mirrors +from .list_cmd import list_mirrors from .merge_cmd import merge_mirrors from .setup_cmd import setup_mirrors +from .types import MirrorMap, Repository from .visibility_cmd import set_mirror_visibility __all__ = [ - "Repository", "MirrorMap", - "list_mirrors", + "Repository", "diff_mirrors", + "list_mirrors", "merge_mirrors", - "setup_mirrors", "set_mirror_visibility", + "setup_mirrors", ] diff --git a/src/pkgmgr/actions/mirror/git_remote.py b/src/pkgmgr/actions/mirror/git_remote.py index bed95d5..c0daec2 100644 --- a/src/pkgmgr/actions/mirror/git_remote.py +++ b/src/pkgmgr/actions/mirror/git_remote.py @@ -3,7 +3,6 @@ from __future__ import annotations import os from typing import Optional, Set -from pkgmgr.core.git.errors import GitRunError from pkgmgr.core.git.commands import ( GitAddRemoteError, GitAddRemotePushUrlError, @@ -12,6 +11,7 @@ from pkgmgr.core.git.commands import ( add_remote_push_url, set_remote_url, ) +from pkgmgr.core.git.errors import GitRunError from pkgmgr.core.git.queries import get_remote_push_urls, list_remotes from .types import MirrorMap, RepoMirrorContext, Repository diff --git a/src/pkgmgr/actions/mirror/merge_cmd.py b/src/pkgmgr/actions/mirror/merge_cmd.py index 448020b..7f9cca8 100644 --- a/src/pkgmgr/actions/mirror/merge_cmd.py +++ b/src/pkgmgr/actions/mirror/merge_cmd.py @@ -1,7 +1,7 @@ from __future__ import annotations import os -from typing import Dict, List, Tuple, Optional +from typing import Dict, List, Optional, Tuple import yaml @@ -11,7 +11,6 @@ from .context import build_context from .io import write_mirrors_file from .types import MirrorMap, Repository - # ----------------------------------------------------------------------------- # Helpers # ----------------------------------------------------------------------------- diff --git a/src/pkgmgr/actions/mirror/url_utils.py b/src/pkgmgr/actions/mirror/url_utils.py index 61e392f..8515435 100644 --- a/src/pkgmgr/actions/mirror/url_utils.py +++ b/src/pkgmgr/actions/mirror/url_utils.py @@ -1,8 +1,8 @@ # src/pkgmgr/actions/mirror/url_utils.py from __future__ import annotations -from urllib.parse import urlparse from typing import Optional, Tuple +from urllib.parse import urlparse def hostport_from_git_url(url: str) -> Tuple[str, Optional[str]]: diff --git a/src/pkgmgr/actions/proxy.py b/src/pkgmgr/actions/proxy.py index c8b2171..5d17935 100644 --- a/src/pkgmgr/actions/proxy.py +++ b/src/pkgmgr/actions/proxy.py @@ -1,9 +1,10 @@ import os -from pkgmgr.core.repository.identifier import get_repo_identifier -from pkgmgr.core.repository.dir import get_repo_dir -from pkgmgr.core.command.run import run_command import sys +from pkgmgr.core.command.run import run_command +from pkgmgr.core.repository.dir import get_repo_dir +from pkgmgr.core.repository.identifier import get_repo_identifier + def exec_proxy_command( proxy_prefix: str, diff --git a/src/pkgmgr/actions/release/files/__init__.py b/src/pkgmgr/actions/release/files/__init__.py index 7556384..3c56045 100644 --- a/src/pkgmgr/actions/release/files/__init__.py +++ b/src/pkgmgr/actions/release/files/__init__.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ Backwards-compatible facade for the release file update helpers. @@ -13,23 +12,23 @@ Keep this package stable so existing imports continue to work, e.g.: from __future__ import annotations -from .editor import _open_editor_for_changelog -from .pyproject import update_pyproject_version -from .flake import update_flake_version -from .pkgbuild import update_pkgbuild_version -from .rpm_spec import update_spec_version from .changelog_md import update_changelog from .debian import _get_debian_author, update_debian_changelog +from .editor import _open_editor_for_changelog +from .flake import update_flake_version +from .pkgbuild import update_pkgbuild_version +from .pyproject import update_pyproject_version from .rpm_changelog import update_spec_changelog +from .rpm_spec import update_spec_version __all__ = [ + "_get_debian_author", "_open_editor_for_changelog", - "update_pyproject_version", + "update_changelog", + "update_debian_changelog", "update_flake_version", "update_pkgbuild_version", - "update_spec_version", - "update_changelog", - "_get_debian_author", - "update_debian_changelog", + "update_pyproject_version", "update_spec_changelog", + "update_spec_version", ] diff --git a/src/pkgmgr/actions/release/package_name.py b/src/pkgmgr/actions/release/package_name.py index c77d4ca..0306634 100644 --- a/src/pkgmgr/actions/release/package_name.py +++ b/src/pkgmgr/actions/release/package_name.py @@ -28,7 +28,6 @@ from typing import Optional from pkgmgr.core.repository.paths import RepoPaths - _DEBIAN_PACKAGE_RE = re.compile(r"^Package:\s*(\S+)\s*$", re.MULTILINE) _PKGBUILD_NAME_RE = re.compile(r"^pkgname=([^\s#]+)\s*$", re.MULTILINE) _RPM_NAME_RE = re.compile(r"^Name:\s*(\S+)\s*$", re.MULTILINE) diff --git a/src/pkgmgr/actions/release/versioning.py b/src/pkgmgr/actions/release/versioning.py index 813eb4e..481e2f3 100644 --- a/src/pkgmgr/actions/release/versioning.py +++ b/src/pkgmgr/actions/release/versioning.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ Version discovery and bumping helpers for the release workflow. @@ -10,10 +9,10 @@ from __future__ import annotations from pkgmgr.core.git.queries import get_tags from pkgmgr.core.version.semver import ( SemVer, - find_latest_version, bump_major, bump_minor, bump_patch, + find_latest_version, ) diff --git a/src/pkgmgr/actions/repository/clone.py b/src/pkgmgr/actions/repository/clone.py index 5dcc326..6fe7c88 100644 --- a/src/pkgmgr/actions/repository/clone.py +++ b/src/pkgmgr/actions/repository/clone.py @@ -3,7 +3,8 @@ from __future__ import annotations import os from typing import Any, Dict, List, Optional -from pkgmgr.core.git.commands import clone as git_clone, GitCloneError +from pkgmgr.core.git.commands import GitCloneError +from pkgmgr.core.git.commands import clone as git_clone from pkgmgr.core.repository.dir import get_repo_dir from pkgmgr.core.repository.identifier import get_repo_identifier from pkgmgr.core.repository.verify import verify_repository diff --git a/src/pkgmgr/actions/repository/create/config_writer.py b/src/pkgmgr/actions/repository/create/config_writer.py index 622ccf8..3711484 100644 --- a/src/pkgmgr/actions/repository/create/config_writer.py +++ b/src/pkgmgr/actions/repository/create/config_writer.py @@ -1,7 +1,7 @@ from __future__ import annotations import os -from typing import Dict, Any, Set +from typing import Any, Dict, Set import yaml diff --git a/src/pkgmgr/actions/repository/create/parser.py b/src/pkgmgr/actions/repository/create/parser.py index ef789cb..e347e2b 100644 --- a/src/pkgmgr/actions/repository/create/parser.py +++ b/src/pkgmgr/actions/repository/create/parser.py @@ -58,7 +58,7 @@ def _split_host_port(host: str) -> Tuple[str, str | None]: def _strip_git_suffix(name: str) -> str: - return name[:-4] if name.endswith(".git") else name + return name.removesuffix(".git") def _ensure_valid_repo_name(name: str) -> None: diff --git a/src/pkgmgr/actions/repository/create/planner.py b/src/pkgmgr/actions/repository/create/planner.py index 782e85b..ca43cde 100644 --- a/src/pkgmgr/actions/repository/create/planner.py +++ b/src/pkgmgr/actions/repository/create/planner.py @@ -1,7 +1,7 @@ from __future__ import annotations import os -from typing import Dict, Any +from typing import Any, Dict from .model import RepoParts diff --git a/src/pkgmgr/actions/repository/create/service.py b/src/pkgmgr/actions/repository/create/service.py index 548d55e..4a8e754 100644 --- a/src/pkgmgr/actions/repository/create/service.py +++ b/src/pkgmgr/actions/repository/create/service.py @@ -1,16 +1,16 @@ from __future__ import annotations import os -from typing import Dict, Any +from typing import Any, Dict from pkgmgr.core.git.queries import get_config_value -from .parser import parse_identifier -from .planner import CreateRepoPlanner from .config_writer import ConfigRepoWriter -from .templates import TemplateRenderer from .git_bootstrap import GitBootstrapper from .mirrors import MirrorBootstrapper +from .parser import parse_identifier +from .planner import CreateRepoPlanner +from .templates import TemplateRenderer class CreateRepoService: diff --git a/src/pkgmgr/actions/repository/create/templates.py b/src/pkgmgr/actions/repository/create/templates.py index 8d566b2..ac849f1 100644 --- a/src/pkgmgr/actions/repository/create/templates.py +++ b/src/pkgmgr/actions/repository/create/templates.py @@ -2,7 +2,7 @@ from __future__ import annotations import os from pathlib import Path -from typing import Dict, Any +from typing import Any, Dict from pkgmgr.core.git.queries import get_repo_root diff --git a/src/pkgmgr/actions/repository/delete.py b/src/pkgmgr/actions/repository/delete.py index 19caacd..f08d01c 100644 --- a/src/pkgmgr/actions/repository/delete.py +++ b/src/pkgmgr/actions/repository/delete.py @@ -1,7 +1,8 @@ -import shutil import os -from pkgmgr.core.repository.identifier import get_repo_identifier +import shutil + from pkgmgr.core.repository.dir import get_repo_dir +from pkgmgr.core.repository.identifier import get_repo_identifier def delete_repos(selected_repos, repositories_base_dir, all_repos, preview=False): diff --git a/src/pkgmgr/actions/repository/list.py b/src/pkgmgr/actions/repository/list.py index f3c401f..7b42ff9 100644 --- a/src/pkgmgr/actions/repository/list.py +++ b/src/pkgmgr/actions/repository/list.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ Pretty-print repository list with status, categories, tags and path. diff --git a/src/pkgmgr/actions/repository/pull.py b/src/pkgmgr/actions/repository/pull.py index 4f13237..3983088 100644 --- a/src/pkgmgr/actions/repository/pull.py +++ b/src/pkgmgr/actions/repository/pull.py @@ -5,9 +5,9 @@ from concurrent.futures import ThreadPoolExecutor from typing import Any, Dict, List, Tuple from pkgmgr.actions.repository._parallel import RepoRef, run_on_repos -from pkgmgr.core.git.commands import pull_args, GitPullArgsError -from pkgmgr.core.repository.identifier import get_repo_identifier +from pkgmgr.core.git.commands import GitPullArgsError, pull_args from pkgmgr.core.repository.dir import get_repo_dir +from pkgmgr.core.repository.identifier import get_repo_identifier from pkgmgr.core.repository.verify import verify_repository Repository = Dict[str, Any] diff --git a/src/pkgmgr/actions/repository/push.py b/src/pkgmgr/actions/repository/push.py index 0a42d1f..f80dbc0 100644 --- a/src/pkgmgr/actions/repository/push.py +++ b/src/pkgmgr/actions/repository/push.py @@ -6,7 +6,7 @@ from pkgmgr.actions.repository._parallel import ( resolve_repos, run_on_repos, ) -from pkgmgr.core.git.commands import push_args, GitPushArgsError +from pkgmgr.core.git.commands import GitPushArgsError, push_args Repository = Dict[str, Any] diff --git a/src/pkgmgr/actions/update/__init__.py b/src/pkgmgr/actions/update/__init__.py index d0a5b7d..e91f6d8 100644 --- a/src/pkgmgr/actions/update/__init__.py +++ b/src/pkgmgr/actions/update/__init__.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- from __future__ import annotations diff --git a/src/pkgmgr/actions/update/manager.py b/src/pkgmgr/actions/update/manager.py index d5ae220..5bc504e 100644 --- a/src/pkgmgr/actions/update/manager.py +++ b/src/pkgmgr/actions/update/manager.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- from __future__ import annotations -from typing import Any, Iterable, List, Tuple +from collections.abc import Iterable +from typing import Any, List, Tuple from pkgmgr.actions.update.system_updater import SystemUpdater diff --git a/src/pkgmgr/actions/update/os_release.py b/src/pkgmgr/actions/update/os_release.py index 175f172..641caff 100644 --- a/src/pkgmgr/actions/update/os_release.py +++ b/src/pkgmgr/actions/update/os_release.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- from __future__ import annotations @@ -37,7 +36,7 @@ class OSReleaseInfo: pretty_name: str = "" @staticmethod - def load() -> "OSReleaseInfo": + def load() -> OSReleaseInfo: data = read_os_release() return OSReleaseInfo( id=(data.get("ID") or "").lower(), diff --git a/src/pkgmgr/actions/update/system_updater.py b/src/pkgmgr/actions/update/system_updater.py index 5358f98..a2a5363 100644 --- a/src/pkgmgr/actions/update/system_updater.py +++ b/src/pkgmgr/actions/update/system_updater.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- from __future__ import annotations diff --git a/src/pkgmgr/cli/__init__.py b/src/pkgmgr/cli/__init__.py index 5f7e7dd..9b57d70 100644 --- a/src/pkgmgr/cli/__init__.py +++ b/src/pkgmgr/cli/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import annotations import os @@ -6,8 +5,8 @@ import os from pkgmgr.core.config.load import load_config from .context import CLIContext -from .parser import create_parser from .dispatch import dispatch_command +from .parser import create_parser __all__ = ["CLIContext", "create_parser", "dispatch_command", "main"] diff --git a/src/pkgmgr/cli/commands/__init__.py b/src/pkgmgr/cli/commands/__init__.py index 9bdc8ef..ce6fb90 100644 --- a/src/pkgmgr/cli/commands/__init__.py +++ b/src/pkgmgr/cli/commands/__init__.py @@ -1,27 +1,27 @@ from .archive import handle_archive -from .code_scanning import handle_code_scanning -from .repos import handle_repos_command -from .config import handle_config -from .tools import handle_tools_command -from .release import handle_release -from .publish import handle_publish -from .version import handle_version -from .make import handle_make -from .changelog import handle_changelog from .branch import handle_branch +from .changelog import handle_changelog +from .code_scanning import handle_code_scanning +from .config import handle_config +from .make import handle_make from .mirror import handle_mirror_command +from .publish import handle_publish +from .release import handle_release +from .repos import handle_repos_command +from .tools import handle_tools_command +from .version import handle_version __all__ = [ "handle_archive", - "handle_code_scanning", - "handle_repos_command", - "handle_config", - "handle_tools_command", - "handle_release", - "handle_publish", - "handle_version", - "handle_make", - "handle_changelog", "handle_branch", + "handle_changelog", + "handle_code_scanning", + "handle_config", + "handle_make", "handle_mirror_command", + "handle_publish", + "handle_release", + "handle_repos_command", + "handle_tools_command", + "handle_version", ] diff --git a/src/pkgmgr/cli/commands/branch.py b/src/pkgmgr/cli/commands/branch.py index 3838bab..e1adb9c 100644 --- a/src/pkgmgr/cli/commands/branch.py +++ b/src/pkgmgr/cli/commands/branch.py @@ -2,8 +2,8 @@ from __future__ import annotations import sys +from pkgmgr.actions.branch import close_branch, drop_branch, open_branch from pkgmgr.cli.context import CLIContext -from pkgmgr.actions.branch import open_branch, close_branch, drop_branch def handle_branch(args, ctx: CLIContext) -> None: diff --git a/src/pkgmgr/cli/commands/changelog.py b/src/pkgmgr/cli/commands/changelog.py index baa959f..8f97356 100644 --- a/src/pkgmgr/cli/commands/changelog.py +++ b/src/pkgmgr/cli/commands/changelog.py @@ -4,13 +4,12 @@ import os import sys from typing import Any, Dict, List, Optional, Tuple +from pkgmgr.actions.changelog import generate_changelog from pkgmgr.cli.context import CLIContext +from pkgmgr.core.git.queries import get_tags from pkgmgr.core.repository.dir import get_repo_dir from pkgmgr.core.repository.identifier import get_repo_identifier -from pkgmgr.core.git.queries import get_tags from pkgmgr.core.version.semver import extract_semver_from_tags -from pkgmgr.actions.changelog import generate_changelog - Repository = Dict[str, Any] diff --git a/src/pkgmgr/cli/commands/config.py b/src/pkgmgr/cli/commands/config.py index d2bff0b..462416e 100644 --- a/src/pkgmgr/cli/commands/config.py +++ b/src/pkgmgr/cli/commands/config.py @@ -5,20 +5,20 @@ from __future__ import annotations import os -import sys import shutil +import sys from pathlib import Path from typing import Any, Dict, Optional import yaml -from pkgmgr.cli.context import CLIContext -from pkgmgr.actions.config.init import config_init from pkgmgr.actions.config.add import interactive_add -from pkgmgr.core.repository.resolve import resolve_repos -from pkgmgr.core.config.save import save_user_config +from pkgmgr.actions.config.init import config_init from pkgmgr.actions.config.show import show_config +from pkgmgr.cli.context import CLIContext from pkgmgr.core.command.run import run_command +from pkgmgr.core.config.save import save_user_config +from pkgmgr.core.repository.resolve import resolve_repos def _load_user_config(user_config_path: str) -> Dict[str, Any]: diff --git a/src/pkgmgr/cli/commands/make.py b/src/pkgmgr/cli/commands/make.py index b4f61e2..cf7c399 100644 --- a/src/pkgmgr/cli/commands/make.py +++ b/src/pkgmgr/cli/commands/make.py @@ -3,9 +3,8 @@ from __future__ import annotations import sys from typing import Any, Dict, List -from pkgmgr.cli.context import CLIContext from pkgmgr.actions.proxy import exec_proxy_command - +from pkgmgr.cli.context import CLIContext Repository = Dict[str, Any] diff --git a/src/pkgmgr/cli/commands/release.py b/src/pkgmgr/cli/commands/release.py index cf74c43..29d915e 100644 --- a/src/pkgmgr/cli/commands/release.py +++ b/src/pkgmgr/cli/commands/release.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- from __future__ import annotations diff --git a/src/pkgmgr/cli/commands/repos.py b/src/pkgmgr/cli/commands/repos.py index f52467c..ea248de 100644 --- a/src/pkgmgr/cli/commands/repos.py +++ b/src/pkgmgr/cli/commands/repos.py @@ -1,18 +1,17 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- from __future__ import annotations import sys from typing import Any, Dict, List -from pkgmgr.cli.context import CLIContext from pkgmgr.actions.install import install_repos +from pkgmgr.actions.repository.create import create_repo from pkgmgr.actions.repository.deinstall import deinstall_repos from pkgmgr.actions.repository.delete import delete_repos -from pkgmgr.actions.repository.status import status_repos from pkgmgr.actions.repository.list import list_repositories -from pkgmgr.actions.repository.create import create_repo +from pkgmgr.actions.repository.status import status_repos +from pkgmgr.cli.context import CLIContext from pkgmgr.core.command.run import run_command from pkgmgr.core.repository.dir import get_repo_dir diff --git a/src/pkgmgr/cli/commands/version.py b/src/pkgmgr/cli/commands/version.py index a388554..d86bc8d 100644 --- a/src/pkgmgr/cli/commands/version.py +++ b/src/pkgmgr/cli/commands/version.py @@ -5,22 +5,22 @@ import sys from typing import Any, Dict, List, Optional, Tuple from pkgmgr.cli.context import CLIContext +from pkgmgr.core.git.queries import get_tags from pkgmgr.core.repository.dir import get_repo_dir from pkgmgr.core.repository.identifier import get_repo_identifier -from pkgmgr.core.git.queries import get_tags -from pkgmgr.core.version.semver import SemVer, find_latest_version from pkgmgr.core.version.installed import ( - get_installed_python_version, get_installed_nix_profile_version, + get_installed_python_version, ) +from pkgmgr.core.version.semver import SemVer, find_latest_version from pkgmgr.core.version.source import ( - read_pyproject_version, - read_pyproject_project_name, + read_ansible_galaxy_version, + read_debian_changelog_version, read_flake_version, read_pkgbuild_version, - read_debian_changelog_version, + read_pyproject_project_name, + read_pyproject_version, read_spec_version, - read_ansible_galaxy_version, ) Repository = Dict[str, Any] diff --git a/src/pkgmgr/cli/dispatch.py b/src/pkgmgr/cli/dispatch.py index 4a718d7..db7f305 100644 --- a/src/pkgmgr/cli/dispatch.py +++ b/src/pkgmgr/cli/dispatch.py @@ -2,27 +2,26 @@ from __future__ import annotations import os import sys -from typing import List, Dict, Any - -from pkgmgr.cli.context import CLIContext -from pkgmgr.cli.proxy import maybe_handle_proxy -from pkgmgr.core.repository.selected import get_selected_repos -from pkgmgr.core.repository.dir import get_repo_dir +from typing import Any, Dict, List from pkgmgr.cli.commands import ( handle_archive, + handle_branch, + handle_changelog, handle_code_scanning, - handle_repos_command, - handle_tools_command, - handle_release, - handle_publish, - handle_version, handle_config, handle_make, - handle_changelog, - handle_branch, handle_mirror_command, + handle_publish, + handle_release, + handle_repos_command, + handle_tools_command, + handle_version, ) +from pkgmgr.cli.context import CLIContext +from pkgmgr.cli.proxy import maybe_handle_proxy +from pkgmgr.core.repository.dir import get_repo_dir +from pkgmgr.core.repository.selected import get_selected_repos def _has_explicit_selection(args) -> bool: diff --git a/src/pkgmgr/cli/parser/__init__.py b/src/pkgmgr/cli/parser/__init__.py index 390ca88..4f366ee 100644 --- a/src/pkgmgr/cli/parser/__init__.py +++ b/src/pkgmgr/cli/parser/__init__.py @@ -74,4 +74,4 @@ def create_parser(description_text: str) -> argparse.ArgumentParser: return parser -__all__ = ["create_parser", "SortedSubParsersAction"] +__all__ = ["SortedSubParsersAction", "create_parser"] diff --git a/src/pkgmgr/cli/parser/branch_cmd.py b/src/pkgmgr/cli/parser/branch_cmd.py index f9ab028..d31545f 100644 --- a/src/pkgmgr/cli/parser/branch_cmd.py +++ b/src/pkgmgr/cli/parser/branch_cmd.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- from __future__ import annotations diff --git a/src/pkgmgr/cli/parser/changelog_cmd.py b/src/pkgmgr/cli/parser/changelog_cmd.py index 76e6123..8896f22 100644 --- a/src/pkgmgr/cli/parser/changelog_cmd.py +++ b/src/pkgmgr/cli/parser/changelog_cmd.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- from __future__ import annotations diff --git a/src/pkgmgr/cli/parser/config_cmd.py b/src/pkgmgr/cli/parser/config_cmd.py index ecd15b6..7d48c74 100644 --- a/src/pkgmgr/cli/parser/config_cmd.py +++ b/src/pkgmgr/cli/parser/config_cmd.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- from __future__ import annotations diff --git a/src/pkgmgr/cli/parser/install_update.py b/src/pkgmgr/cli/parser/install_update.py index 5993a5e..b2d7897 100644 --- a/src/pkgmgr/cli/parser/install_update.py +++ b/src/pkgmgr/cli/parser/install_update.py @@ -1,11 +1,10 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- import argparse from pkgmgr.cli.parser.common import ( - add_install_update_arguments, add_identifier_arguments, + add_install_update_arguments, ) diff --git a/src/pkgmgr/cli/parser/list_cmd.py b/src/pkgmgr/cli/parser/list_cmd.py index 78a7085..7eaead5 100644 --- a/src/pkgmgr/cli/parser/list_cmd.py +++ b/src/pkgmgr/cli/parser/list_cmd.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- from __future__ import annotations diff --git a/src/pkgmgr/cli/parser/make_cmd.py b/src/pkgmgr/cli/parser/make_cmd.py index 0aebb18..661b4b9 100644 --- a/src/pkgmgr/cli/parser/make_cmd.py +++ b/src/pkgmgr/cli/parser/make_cmd.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- from __future__ import annotations diff --git a/src/pkgmgr/cli/parser/mirror_cmd.py b/src/pkgmgr/cli/parser/mirror_cmd.py index 0a6e860..2287afa 100644 --- a/src/pkgmgr/cli/parser/mirror_cmd.py +++ b/src/pkgmgr/cli/parser/mirror_cmd.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- from __future__ import annotations diff --git a/src/pkgmgr/cli/parser/navigation_cmd.py b/src/pkgmgr/cli/parser/navigation_cmd.py index f449181..4bca222 100644 --- a/src/pkgmgr/cli/parser/navigation_cmd.py +++ b/src/pkgmgr/cli/parser/navigation_cmd.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- from __future__ import annotations diff --git a/src/pkgmgr/cli/parser/release_cmd.py b/src/pkgmgr/cli/parser/release_cmd.py index 01c94a0..5f84078 100644 --- a/src/pkgmgr/cli/parser/release_cmd.py +++ b/src/pkgmgr/cli/parser/release_cmd.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- from __future__ import annotations diff --git a/src/pkgmgr/cli/parser/version_cmd.py b/src/pkgmgr/cli/parser/version_cmd.py index c0c07a9..267c12a 100644 --- a/src/pkgmgr/cli/parser/version_cmd.py +++ b/src/pkgmgr/cli/parser/version_cmd.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- from __future__ import annotations diff --git a/src/pkgmgr/cli/proxy.py b/src/pkgmgr/cli/proxy.py index a4d1244..e219a72 100644 --- a/src/pkgmgr/cli/proxy.py +++ b/src/pkgmgr/cli/proxy.py @@ -1,21 +1,19 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- from __future__ import annotations import argparse import os import sys -from typing import Dict, List, Any +from typing import Any, Dict, List -from pkgmgr.cli.context import CLIContext -from pkgmgr.actions.repository.clone import clone_repos from pkgmgr.actions.proxy import exec_proxy_command +from pkgmgr.actions.repository.clone import clone_repos from pkgmgr.actions.repository.pull import pull_with_verification from pkgmgr.actions.repository.push import push_in_parallel -from pkgmgr.core.repository.selected import get_selected_repos +from pkgmgr.cli.context import CLIContext from pkgmgr.core.repository.dir import get_repo_dir - +from pkgmgr.core.repository.selected import get_selected_repos PROXY_COMMANDS: Dict[str, List[str]] = { "git": [ diff --git a/src/pkgmgr/core/command/alias.py b/src/pkgmgr/core/command/alias.py index d03b132..55b2616 100644 --- a/src/pkgmgr/core/command/alias.py +++ b/src/pkgmgr/core/command/alias.py @@ -1,5 +1,5 @@ -import os import hashlib +import os import re diff --git a/src/pkgmgr/core/command/ink.py b/src/pkgmgr/core/command/ink.py index adb5dac..9d48178 100644 --- a/src/pkgmgr/core/command/ink.py +++ b/src/pkgmgr/core/command/ink.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- import os -from pkgmgr.core.repository.identifier import get_repo_identifier + from pkgmgr.core.repository.dir import get_repo_dir +from pkgmgr.core.repository.identifier import get_repo_identifier def create_ink( diff --git a/src/pkgmgr/core/command/resolve.py b/src/pkgmgr/core/command/resolve.py index e293c9b..7bfb583 100644 --- a/src/pkgmgr/core/command/resolve.py +++ b/src/pkgmgr/core/command/resolve.py @@ -1,7 +1,6 @@ import os import shutil -from typing import Optional, List, Dict, Any - +from typing import Any, Dict, List, Optional Repository = Dict[str, Any] diff --git a/src/pkgmgr/core/config/save.py b/src/pkgmgr/core/config/save.py index d2dfc56..3477318 100644 --- a/src/pkgmgr/core/config/save.py +++ b/src/pkgmgr/core/config/save.py @@ -1,6 +1,7 @@ -import yaml import os +import yaml + def save_user_config(user_config, USER_CONFIG_PATH: str): """Save the user configuration to USER_CONFIG_PATH.""" diff --git a/src/pkgmgr/core/credentials/__init__.py b/src/pkgmgr/core/credentials/__init__.py index 2bf1bbc..28bb283 100644 --- a/src/pkgmgr/core/credentials/__init__.py +++ b/src/pkgmgr/core/credentials/__init__.py @@ -10,11 +10,11 @@ from .types import ( ) __all__ = [ - "TokenResolver", - "ResolutionOptions", "CredentialError", - "NoCredentialsError", "KeyringUnavailableError", + "NoCredentialsError", + "ResolutionOptions", "TokenRequest", + "TokenResolver", "TokenResult", ] diff --git a/src/pkgmgr/core/credentials/providers/__init__.py b/src/pkgmgr/core/credentials/providers/__init__.py index bdcf2bf..41dc8cf 100644 --- a/src/pkgmgr/core/credentials/providers/__init__.py +++ b/src/pkgmgr/core/credentials/providers/__init__.py @@ -1,13 +1,13 @@ """Credential providers used by TokenResolver.""" from .env import EnvTokenProvider +from .gh import GhTokenProvider from .keyring import KeyringTokenProvider from .prompt import PromptTokenProvider -from .gh import GhTokenProvider __all__ = [ "EnvTokenProvider", + "GhTokenProvider", "KeyringTokenProvider", "PromptTokenProvider", - "GhTokenProvider", ] diff --git a/src/pkgmgr/core/credentials/providers/keyring.py b/src/pkgmgr/core/credentials/providers/keyring.py index 0e3fd8f..9b7a1ed 100644 --- a/src/pkgmgr/core/credentials/providers/keyring.py +++ b/src/pkgmgr/core/credentials/providers/keyring.py @@ -20,14 +20,14 @@ def _import_keyring(): """ try: import keyring # type: ignore - except Exception as exc: # noqa: BLE001 + except Exception as exc: raise KeyringUnavailableError("python-keyring is not installed.") from exc # Some environments have keyring installed but no usable backend. # We do a lightweight "backend sanity check" by attempting to read the backend. try: _ = keyring.get_keyring() - except Exception as exc: # noqa: BLE001 + except Exception as exc: raise KeyringUnavailableError( "python-keyring is installed but no usable keyring backend is configured." ) from exc diff --git a/src/pkgmgr/core/credentials/resolver.py b/src/pkgmgr/core/credentials/resolver.py index 7d45690..c9eaea2 100644 --- a/src/pkgmgr/core/credentials/resolver.py +++ b/src/pkgmgr/core/credentials/resolver.py @@ -59,18 +59,18 @@ class TokenResolver: print("[WARN] Keyring support is not available.", file=sys.stderr) print(f" {msg}", file=sys.stderr) print(" Tokens will NOT be persisted securely.", file=sys.stderr) - print("", file=sys.stderr) + print(file=sys.stderr) print( " To enable secure token storage, install python-keyring:", file=sys.stderr, ) print(" pip install keyring", file=sys.stderr) - print("", file=sys.stderr) + print(file=sys.stderr) print(" Or install via system packages:", file=sys.stderr) print(" sudo apt install python3-keyring", file=sys.stderr) print(" sudo pacman -S python-keyring", file=sys.stderr) print(" sudo dnf install python3-keyring", file=sys.stderr) - print("", file=sys.stderr) + print(file=sys.stderr) def _prompt_and_maybe_store( self, diff --git a/src/pkgmgr/core/credentials/validate.py b/src/pkgmgr/core/credentials/validate.py index 9d5c757..de76c73 100644 --- a/src/pkgmgr/core/credentials/validate.py +++ b/src/pkgmgr/core/credentials/validate.py @@ -1,7 +1,7 @@ from __future__ import annotations -import urllib.request import json +import urllib.request def validate_token(provider_kind: str, host: str, token: str) -> bool: diff --git a/src/pkgmgr/core/git/commands/__init__.py b/src/pkgmgr/core/git/commands/__init__.py index 16bc55d..d072886 100644 --- a/src/pkgmgr/core/git/commands/__init__.py +++ b/src/pkgmgr/core/git/commands/__init__.py @@ -26,50 +26,50 @@ from .tag_annotated import GitTagAnnotatedError, tag_annotated from .tag_force_annotated import GitTagForceAnnotatedError, tag_force_annotated __all__ = [ + "GitAddAllError", + "GitAddError", + "GitAddRemoteError", + "GitAddRemotePushUrlError", + "GitBranchMoveError", + "GitCheckoutError", + "GitCloneError", + "GitCommitError", + "GitCreateBranchError", + "GitDeleteLocalBranchError", + "GitDeleteRemoteBranchError", + "GitFetchError", + "GitInitError", + "GitMergeError", + "GitPullArgsError", + "GitPullError", + "GitPullFfOnlyError", + "GitPushArgsError", + "GitPushError", + "GitPushUpstreamError", + "GitSetRemoteUrlError", + "GitTagAnnotatedError", + "GitTagForceAnnotatedError", "add", "add_all", - "fetch", + "add_remote", + "add_remote_push_url", + "branch_move", "checkout", + "clone", + "commit", + "create_branch", + "delete_local_branch", + "delete_remote_branch", + "fetch", + "init", + "merge_no_ff", "pull", "pull_args", "pull_ff_only", - "merge_no_ff", "push", "push_args", - "commit", - "delete_local_branch", - "delete_remote_branch", - "create_branch", "push_upstream", - "add_remote", "set_remote_url", - "add_remote_push_url", "tag_annotated", "tag_force_annotated", - "clone", - "init", - "branch_move", - "GitAddError", - "GitAddAllError", - "GitFetchError", - "GitCheckoutError", - "GitPullError", - "GitPullArgsError", - "GitPullFfOnlyError", - "GitMergeError", - "GitPushError", - "GitPushArgsError", - "GitCommitError", - "GitDeleteLocalBranchError", - "GitDeleteRemoteBranchError", - "GitCreateBranchError", - "GitPushUpstreamError", - "GitAddRemoteError", - "GitSetRemoteUrlError", - "GitAddRemotePushUrlError", - "GitTagAnnotatedError", - "GitTagForceAnnotatedError", - "GitCloneError", - "GitInitError", - "GitBranchMoveError", ] diff --git a/src/pkgmgr/core/git/commands/add.py b/src/pkgmgr/core/git/commands/add.py index 1f2da9c..41e9be7 100644 --- a/src/pkgmgr/core/git/commands/add.py +++ b/src/pkgmgr/core/git/commands/add.py @@ -1,8 +1,9 @@ from __future__ import annotations -from typing import Iterable, List, Sequence, Union +from collections.abc import Iterable, Sequence +from typing import List, Union -from ..errors import GitRunError, GitCommandError +from ..errors import GitCommandError, GitRunError from ..run import run diff --git a/src/pkgmgr/core/git/commands/add_remote.py b/src/pkgmgr/core/git/commands/add_remote.py index 586ae06..4bbe05c 100644 --- a/src/pkgmgr/core/git/commands/add_remote.py +++ b/src/pkgmgr/core/git/commands/add_remote.py @@ -1,6 +1,6 @@ from __future__ import annotations -from ..errors import GitRunError, GitCommandError +from ..errors import GitCommandError, GitRunError from ..run import run diff --git a/src/pkgmgr/core/git/commands/add_remote_push_url.py b/src/pkgmgr/core/git/commands/add_remote_push_url.py index 8de6681..85c102d 100644 --- a/src/pkgmgr/core/git/commands/add_remote_push_url.py +++ b/src/pkgmgr/core/git/commands/add_remote_push_url.py @@ -1,6 +1,6 @@ from __future__ import annotations -from ..errors import GitRunError, GitCommandError +from ..errors import GitCommandError, GitRunError from ..run import run diff --git a/src/pkgmgr/core/git/commands/branch_move.py b/src/pkgmgr/core/git/commands/branch_move.py index ea019d3..cbca0da 100644 --- a/src/pkgmgr/core/git/commands/branch_move.py +++ b/src/pkgmgr/core/git/commands/branch_move.py @@ -1,6 +1,6 @@ from __future__ import annotations -from ..errors import GitRunError, GitCommandError +from ..errors import GitCommandError, GitRunError from ..run import run diff --git a/src/pkgmgr/core/git/commands/checkout.py b/src/pkgmgr/core/git/commands/checkout.py index e7700a2..fbb15a0 100644 --- a/src/pkgmgr/core/git/commands/checkout.py +++ b/src/pkgmgr/core/git/commands/checkout.py @@ -1,6 +1,6 @@ from __future__ import annotations -from ..errors import GitRunError, GitCommandError +from ..errors import GitCommandError, GitRunError from ..run import run diff --git a/src/pkgmgr/core/git/commands/clone.py b/src/pkgmgr/core/git/commands/clone.py index a8b66a8..434ada3 100644 --- a/src/pkgmgr/core/git/commands/clone.py +++ b/src/pkgmgr/core/git/commands/clone.py @@ -2,7 +2,7 @@ from __future__ import annotations from typing import List -from ..errors import GitRunError, GitCommandError +from ..errors import GitCommandError, GitRunError from ..run import run diff --git a/src/pkgmgr/core/git/commands/commit.py b/src/pkgmgr/core/git/commands/commit.py index 836610e..27363dd 100644 --- a/src/pkgmgr/core/git/commands/commit.py +++ b/src/pkgmgr/core/git/commands/commit.py @@ -1,6 +1,6 @@ from __future__ import annotations -from ..errors import GitRunError, GitCommandError +from ..errors import GitCommandError, GitRunError from ..run import run diff --git a/src/pkgmgr/core/git/commands/create_branch.py b/src/pkgmgr/core/git/commands/create_branch.py index 31a9eb7..ad510cc 100644 --- a/src/pkgmgr/core/git/commands/create_branch.py +++ b/src/pkgmgr/core/git/commands/create_branch.py @@ -1,6 +1,6 @@ from __future__ import annotations -from ..errors import GitRunError, GitCommandError +from ..errors import GitCommandError, GitRunError from ..run import run diff --git a/src/pkgmgr/core/git/commands/delete_local_branch.py b/src/pkgmgr/core/git/commands/delete_local_branch.py index 45402d5..6e07237 100644 --- a/src/pkgmgr/core/git/commands/delete_local_branch.py +++ b/src/pkgmgr/core/git/commands/delete_local_branch.py @@ -1,6 +1,6 @@ from __future__ import annotations -from ..errors import GitRunError, GitCommandError +from ..errors import GitCommandError, GitRunError from ..run import run diff --git a/src/pkgmgr/core/git/commands/delete_remote_branch.py b/src/pkgmgr/core/git/commands/delete_remote_branch.py index 0ba758d..6a1142b 100644 --- a/src/pkgmgr/core/git/commands/delete_remote_branch.py +++ b/src/pkgmgr/core/git/commands/delete_remote_branch.py @@ -1,6 +1,6 @@ from __future__ import annotations -from ..errors import GitRunError, GitCommandError +from ..errors import GitCommandError, GitRunError from ..run import run diff --git a/src/pkgmgr/core/git/commands/fetch.py b/src/pkgmgr/core/git/commands/fetch.py index 37f1c80..5f745b6 100644 --- a/src/pkgmgr/core/git/commands/fetch.py +++ b/src/pkgmgr/core/git/commands/fetch.py @@ -1,6 +1,6 @@ from __future__ import annotations -from ..errors import GitRunError, GitCommandError +from ..errors import GitCommandError, GitRunError from ..run import run diff --git a/src/pkgmgr/core/git/commands/merge_no_ff.py b/src/pkgmgr/core/git/commands/merge_no_ff.py index 19b3f7b..3f9d7b4 100644 --- a/src/pkgmgr/core/git/commands/merge_no_ff.py +++ b/src/pkgmgr/core/git/commands/merge_no_ff.py @@ -1,6 +1,6 @@ from __future__ import annotations -from ..errors import GitRunError, GitCommandError +from ..errors import GitCommandError, GitRunError from ..run import run diff --git a/src/pkgmgr/core/git/commands/pull.py b/src/pkgmgr/core/git/commands/pull.py index 6754e9e..ba8686c 100644 --- a/src/pkgmgr/core/git/commands/pull.py +++ b/src/pkgmgr/core/git/commands/pull.py @@ -1,6 +1,6 @@ from __future__ import annotations -from ..errors import GitRunError, GitCommandError +from ..errors import GitCommandError, GitRunError from ..run import run diff --git a/src/pkgmgr/core/git/commands/pull_args.py b/src/pkgmgr/core/git/commands/pull_args.py index 8027f58..374ab75 100644 --- a/src/pkgmgr/core/git/commands/pull_args.py +++ b/src/pkgmgr/core/git/commands/pull_args.py @@ -2,7 +2,7 @@ from __future__ import annotations from typing import List -from ..errors import GitRunError, GitCommandError +from ..errors import GitCommandError, GitRunError from ..run import run diff --git a/src/pkgmgr/core/git/commands/pull_ff_only.py b/src/pkgmgr/core/git/commands/pull_ff_only.py index eba343e..754fd08 100644 --- a/src/pkgmgr/core/git/commands/pull_ff_only.py +++ b/src/pkgmgr/core/git/commands/pull_ff_only.py @@ -1,6 +1,6 @@ from __future__ import annotations -from ..errors import GitRunError, GitCommandError +from ..errors import GitCommandError, GitRunError from ..run import run diff --git a/src/pkgmgr/core/git/commands/push.py b/src/pkgmgr/core/git/commands/push.py index 0265072..50ff326 100644 --- a/src/pkgmgr/core/git/commands/push.py +++ b/src/pkgmgr/core/git/commands/push.py @@ -1,6 +1,6 @@ from __future__ import annotations -from ..errors import GitRunError, GitCommandError +from ..errors import GitCommandError, GitRunError from ..run import run diff --git a/src/pkgmgr/core/git/commands/push_args.py b/src/pkgmgr/core/git/commands/push_args.py index d7a897a..c455482 100644 --- a/src/pkgmgr/core/git/commands/push_args.py +++ b/src/pkgmgr/core/git/commands/push_args.py @@ -2,7 +2,7 @@ from __future__ import annotations from typing import List -from ..errors import GitRunError, GitCommandError +from ..errors import GitCommandError, GitRunError from ..run import run diff --git a/src/pkgmgr/core/git/commands/push_upstream.py b/src/pkgmgr/core/git/commands/push_upstream.py index 4991f5d..45719bc 100644 --- a/src/pkgmgr/core/git/commands/push_upstream.py +++ b/src/pkgmgr/core/git/commands/push_upstream.py @@ -1,6 +1,6 @@ from __future__ import annotations -from ..errors import GitRunError, GitCommandError +from ..errors import GitCommandError, GitRunError from ..run import run diff --git a/src/pkgmgr/core/git/commands/set_remote_url.py b/src/pkgmgr/core/git/commands/set_remote_url.py index 8d5c48a..8be4852 100644 --- a/src/pkgmgr/core/git/commands/set_remote_url.py +++ b/src/pkgmgr/core/git/commands/set_remote_url.py @@ -1,6 +1,6 @@ from __future__ import annotations -from ..errors import GitRunError, GitCommandError +from ..errors import GitCommandError, GitRunError from ..run import run diff --git a/src/pkgmgr/core/git/commands/tag_annotated.py b/src/pkgmgr/core/git/commands/tag_annotated.py index 88f9fa9..03df862 100644 --- a/src/pkgmgr/core/git/commands/tag_annotated.py +++ b/src/pkgmgr/core/git/commands/tag_annotated.py @@ -1,6 +1,6 @@ from __future__ import annotations -from ..errors import GitRunError, GitCommandError +from ..errors import GitCommandError, GitRunError from ..run import run diff --git a/src/pkgmgr/core/git/commands/tag_force_annotated.py b/src/pkgmgr/core/git/commands/tag_force_annotated.py index 7c15f4e..1cedc9a 100644 --- a/src/pkgmgr/core/git/commands/tag_force_annotated.py +++ b/src/pkgmgr/core/git/commands/tag_force_annotated.py @@ -1,6 +1,6 @@ from __future__ import annotations -from ..errors import GitRunError, GitCommandError +from ..errors import GitCommandError, GitRunError from ..run import run diff --git a/src/pkgmgr/core/git/queries/__init__.py b/src/pkgmgr/core/git/queries/__init__.py index ad75585..8eeced6 100644 --- a/src/pkgmgr/core/git/queries/__init__.py +++ b/src/pkgmgr/core/git/queries/__init__.py @@ -27,26 +27,26 @@ from .probe_remote_reachable import ( from .resolve_base_branch import GitBaseBranchNotFoundError, resolve_base_branch __all__ = [ + "GitBaseBranchNotFoundError", + "GitChangelogQueryError", + "GitLatestSigningKeyQueryError", + "GitRemoteHeadCommitQueryError", + "GitTagsAtRefQueryError", + "get_changelog", + "get_config_value", "get_current_branch", "get_head_commit", "get_latest_commit", "get_latest_signing_key", - "GitLatestSigningKeyQueryError", "get_remote_head_commit", - "GitRemoteHeadCommitQueryError", - "get_tags", - "resolve_base_branch", - "GitBaseBranchNotFoundError", - "list_remotes", "get_remote_push_urls", + "get_repo_root", + "get_tags", + "get_tags_at_ref", + "get_upstream_ref", + "list_remotes", + "list_tags", "probe_remote_reachable", "probe_remote_reachable_detail", - "get_changelog", - "GitChangelogQueryError", - "get_tags_at_ref", - "GitTagsAtRefQueryError", - "get_config_value", - "get_upstream_ref", - "list_tags", - "get_repo_root", + "resolve_base_branch", ] diff --git a/src/pkgmgr/core/git/queries/get_current_branch.py b/src/pkgmgr/core/git/queries/get_current_branch.py index bca5a68..b63b090 100644 --- a/src/pkgmgr/core/git/queries/get_current_branch.py +++ b/src/pkgmgr/core/git/queries/get_current_branch.py @@ -1,6 +1,7 @@ from __future__ import annotations from typing import Optional + from ..errors import GitRunError from ..run import run diff --git a/src/pkgmgr/core/git/run.py b/src/pkgmgr/core/git/run.py index f60c486..9c93682 100644 --- a/src/pkgmgr/core/git/run.py +++ b/src/pkgmgr/core/git/run.py @@ -3,7 +3,7 @@ from __future__ import annotations import subprocess from typing import List -from .errors import GitRunError, GitNotRepositoryError +from .errors import GitNotRepositoryError, GitRunError def _is_not_repo_error(stderr: str) -> bool: diff --git a/src/pkgmgr/core/remote_provisioning/__init__.py b/src/pkgmgr/core/remote_provisioning/__init__.py index 8501004..ebafcd9 100644 --- a/src/pkgmgr/core/remote_provisioning/__init__.py +++ b/src/pkgmgr/core/remote_provisioning/__init__.py @@ -6,10 +6,10 @@ from .types import EnsureResult, ProviderHint, RepoSpec from .visibility import set_repo_visibility __all__ = [ - "ensure_remote_repo", - "set_repo_visibility", - "RepoSpec", "EnsureResult", "ProviderHint", "ProviderRegistry", + "RepoSpec", + "ensure_remote_repo", + "set_repo_visibility", ] diff --git a/src/pkgmgr/core/remote_provisioning/http/__init__.py b/src/pkgmgr/core/remote_provisioning/http/__init__.py index 4d92051..46f98d9 100644 --- a/src/pkgmgr/core/remote_provisioning/http/__init__.py +++ b/src/pkgmgr/core/remote_provisioning/http/__init__.py @@ -2,4 +2,4 @@ from .client import HttpClient, HttpResponse from .errors import HttpError -__all__ = ["HttpClient", "HttpResponse", "HttpError"] +__all__ = ["HttpClient", "HttpError", "HttpResponse"] diff --git a/src/pkgmgr/core/remote_provisioning/providers/__init__.py b/src/pkgmgr/core/remote_provisioning/providers/__init__.py index 2fe2e0b..260e7de 100644 --- a/src/pkgmgr/core/remote_provisioning/providers/__init__.py +++ b/src/pkgmgr/core/remote_provisioning/providers/__init__.py @@ -3,4 +3,4 @@ from .base import RemoteProvider from .gitea import GiteaProvider from .github import GitHubProvider -__all__ = ["RemoteProvider", "GiteaProvider", "GitHubProvider"] +__all__ = ["GitHubProvider", "GiteaProvider", "RemoteProvider"] diff --git a/src/pkgmgr/core/remote_provisioning/registry.py b/src/pkgmgr/core/remote_provisioning/registry.py index 26dfd1b..04de497 100644 --- a/src/pkgmgr/core/remote_provisioning/registry.py +++ b/src/pkgmgr/core/remote_provisioning/registry.py @@ -16,7 +16,7 @@ class ProviderRegistry: providers: List[RemoteProvider] @classmethod - def default(cls) -> "ProviderRegistry": + def default(cls) -> ProviderRegistry: # Order matters: more specific providers first; fallback providers last. return cls(providers=[GitHubProvider(), GiteaProvider()]) diff --git a/src/pkgmgr/core/repository/paths.py b/src/pkgmgr/core/repository/paths.py index c231fe3..b7f1a79 100644 --- a/src/pkgmgr/core/repository/paths.py +++ b/src/pkgmgr/core/repository/paths.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ Central repository path resolver. @@ -19,8 +18,9 @@ should use this module instead of hardcoding paths. from __future__ import annotations import os +from collections.abc import Iterable from dataclasses import dataclass -from typing import Iterable, Optional +from typing import Optional @dataclass(frozen=True) diff --git a/src/pkgmgr/core/repository/resolve.py b/src/pkgmgr/core/repository/resolve.py index ce7c5fc..3689e28 100644 --- a/src/pkgmgr/core/repository/resolve.py +++ b/src/pkgmgr/core/repository/resolve.py @@ -13,9 +13,7 @@ def resolve_repos(identifiers: [], all_repos: []): full_id = ( f"{repo.get('provider')}/{repo.get('account')}/{repo.get('repository')}" ) - if ident == full_id: - matches.append(repo) - elif ident == repo.get("alias"): + if ident == full_id or ident == repo.get("alias"): matches.append(repo) elif ident == repo.get("repository"): # Only match if repository name is unique among all_repos. diff --git a/src/pkgmgr/core/repository/selected.py b/src/pkgmgr/core/repository/selected.py index d19d221..71c317d 100644 --- a/src/pkgmgr/core/repository/selected.py +++ b/src/pkgmgr/core/repository/selected.py @@ -1,14 +1,14 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- from __future__ import annotations import os import re -from typing import Any, Dict, List, Sequence +from collections.abc import Sequence +from typing import Any, Dict, List -from pkgmgr.core.repository.resolve import resolve_repos from pkgmgr.core.repository.ignored import filter_ignored +from pkgmgr.core.repository.resolve import resolve_repos Repository = Dict[str, Any] diff --git a/src/pkgmgr/core/repository/verify.py b/src/pkgmgr/core/repository/verify.py index 94a33f9..c01b69d 100644 --- a/src/pkgmgr/core/repository/verify.py +++ b/src/pkgmgr/core/repository/verify.py @@ -1,11 +1,11 @@ from __future__ import annotations from pkgmgr.core.git.queries import ( + GitLatestSigningKeyQueryError, + GitRemoteHeadCommitQueryError, get_head_commit, get_latest_signing_key, get_remote_head_commit, - GitLatestSigningKeyQueryError, - GitRemoteHeadCommitQueryError, ) diff --git a/src/pkgmgr/core/version/installed.py b/src/pkgmgr/core/version/installed.py index 2bcb5dd..3bd3287 100644 --- a/src/pkgmgr/core/version/installed.py +++ b/src/pkgmgr/core/version/installed.py @@ -4,8 +4,9 @@ import json import re import shutil import subprocess +from collections.abc import Iterable from dataclasses import dataclass -from typing import Iterable, Optional, Tuple +from typing import Optional, Tuple @dataclass(frozen=True) @@ -103,7 +104,7 @@ def _extract_version_from_store_path(path: str) -> Optional[str]: if "-" not in base: return None tail = base.split("-")[-1] - if re.match(r"\d+(\.\d+){0,3}([a-z0-9+._-]*)?$", tail, re.I): + if re.match(r"\d+(\.\d+){0,3}([a-z0-9+._-]*)?$", tail, re.IGNORECASE): return tail return None @@ -158,7 +159,7 @@ def get_installed_nix_profile_version(*candidates: str) -> Optional[InstalledVer norm_line = _normalize(line) for c in norm_candidates: if c in norm_line: - m = re.search(r"\b\d+(\.\d+){0,3}[a-z0-9+._-]*\b", line, re.I) + m = re.search(r"\b\d+(\.\d+){0,3}[a-z0-9+._-]*\b", line, re.IGNORECASE) if m: return InstalledVersion(name=c, version=m.group(0)) if "/nix/store/" in line: diff --git a/src/pkgmgr/core/version/semver.py b/src/pkgmgr/core/version/semver.py index c27337c..77e4a39 100644 --- a/src/pkgmgr/core/version/semver.py +++ b/src/pkgmgr/core/version/semver.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ Utilities for working with semantic versions (SemVer). @@ -11,8 +10,9 @@ heavy dependencies. from __future__ import annotations +from collections.abc import Iterable from dataclasses import dataclass -from typing import Iterable, List, Optional, Tuple +from typing import List, Optional, Tuple @dataclass(frozen=True, order=True) @@ -24,15 +24,14 @@ class SemVer: patch: int @classmethod - def parse(cls, value: str) -> "SemVer": + def parse(cls, value: str) -> SemVer: """ Parse a version string like '1.2.3' or 'v1.2.3' into a SemVer. Raises ValueError if the format is invalid. """ text = value.strip() - if text.startswith("v"): - text = text[1:] + text = text.removeprefix("v") parts = text.split(".") if len(parts) != 3: diff --git a/tests/e2e/test_branch_help.py b/tests/e2e/test_branch_help.py index 1825583..c697e94 100644 --- a/tests/e2e/test_branch_help.py +++ b/tests/e2e/test_branch_help.py @@ -4,7 +4,7 @@ import io import runpy import sys import unittest -from contextlib import redirect_stdout, redirect_stderr +from contextlib import redirect_stderr, redirect_stdout def _run_pkgmgr_help(argv_tail: list[str]) -> str: diff --git a/tests/e2e/test_changelog_commands.py b/tests/e2e/test_changelog_commands.py index 85d9136..eac0462 100644 --- a/tests/e2e/test_changelog_commands.py +++ b/tests/e2e/test_changelog_commands.py @@ -6,8 +6,8 @@ import sys import unittest from test_version_commands import ( - _load_pkgmgr_repo_dir, PROJECT_ROOT, + _load_pkgmgr_repo_dir, ) diff --git a/tests/e2e/test_clone_all.py b/tests/e2e/test_clone_all.py index 98cdbb2..43ed019 100644 --- a/tests/e2e/test_clone_all.py +++ b/tests/e2e/test_clone_all.py @@ -16,8 +16,8 @@ import unittest from test_install_pkgmgr_shallow import ( nix_profile_list_debug, - remove_pkgmgr_from_nix_profile, pkgmgr_help_debug, + remove_pkgmgr_from_nix_profile, ) diff --git a/tests/e2e/test_config_commands.py b/tests/e2e/test_config_commands.py index 1c6d451..ea1ab5e 100644 --- a/tests/e2e/test_config_commands.py +++ b/tests/e2e/test_config_commands.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ Integration tests for the `pkgmgr config` command. diff --git a/tests/e2e/test_install_makefile_three_times.py b/tests/e2e/test_install_makefile_three_times.py index cfc33b5..531472d 100644 --- a/tests/e2e/test_install_makefile_three_times.py +++ b/tests/e2e/test_install_makefile_three_times.py @@ -1,8 +1,9 @@ -from tests.e2e._util import run import tempfile import unittest from pathlib import Path +from tests.e2e._util import run + class TestMakefileThreeTimes(unittest.TestCase): def test_make_install_three_times(self): diff --git a/tests/e2e/test_install_pkgmgr_shallow.py b/tests/e2e/test_install_pkgmgr_shallow.py index c6484bd..ffb1655 100644 --- a/tests/e2e/test_install_pkgmgr_shallow.py +++ b/tests/e2e/test_install_pkgmgr_shallow.py @@ -1,8 +1,8 @@ -import runpy -import sys import os -import unittest +import runpy import subprocess +import sys +import unittest def nix_profile_list_debug(label: str) -> None: diff --git a/tests/e2e/test_install_pkgmgr_three_times_nix.py b/tests/e2e/test_install_pkgmgr_three_times_nix.py index dd97b88..58e2cdc 100644 --- a/tests/e2e/test_install_pkgmgr_three_times_nix.py +++ b/tests/e2e/test_install_pkgmgr_three_times_nix.py @@ -1,9 +1,10 @@ import os -from tests.e2e._util import run import tempfile import unittest from pathlib import Path +from tests.e2e._util import run + class TestPkgmgrInstallThreeTimesNix(unittest.TestCase): def test_three_times_install_nix(self): diff --git a/tests/e2e/test_install_pkgmgr_three_times_venv.py b/tests/e2e/test_install_pkgmgr_three_times_venv.py index 745e513..c340be7 100644 --- a/tests/e2e/test_install_pkgmgr_three_times_venv.py +++ b/tests/e2e/test_install_pkgmgr_three_times_venv.py @@ -1,8 +1,9 @@ -from tests.e2e._util import run +import os import tempfile import unittest from pathlib import Path -import os + +from tests.e2e._util import run class TestPkgmgrInstallThreeTimesVenv(unittest.TestCase): diff --git a/tests/e2e/test_make_commands.py b/tests/e2e/test_make_commands.py index 8234ba6..4a4cf78 100644 --- a/tests/e2e/test_make_commands.py +++ b/tests/e2e/test_make_commands.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ Integration tests for the `pkgmgr make` command. diff --git a/tests/e2e/test_nix_build_pkgmgr.py b/tests/e2e/test_nix_build_pkgmgr.py index 5e6c07d..92f3b29 100644 --- a/tests/e2e/test_nix_build_pkgmgr.py +++ b/tests/e2e/test_nix_build_pkgmgr.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ E2E test to inspect the Nix environment and build the pkgmgr flake @@ -22,7 +21,6 @@ import os import subprocess import unittest - # Resolve project root (the repo where flake.nix lives, e.g. /src) PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) diff --git a/tests/e2e/test_path_commands.py b/tests/e2e/test_path_commands.py index 0966bb6..a8f5eed 100644 --- a/tests/e2e/test_path_commands.py +++ b/tests/e2e/test_path_commands.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ End-to-end tests for the `pkgmgr path` command. diff --git a/tests/e2e/test_publish_commands.py b/tests/e2e/test_publish_commands.py index 25fd84f..04ce4cb 100644 --- a/tests/e2e/test_publish_commands.py +++ b/tests/e2e/test_publish_commands.py @@ -5,7 +5,6 @@ import shutil import subprocess import unittest - PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) diff --git a/tests/e2e/test_release_commands.py b/tests/e2e/test_release_commands.py index 7c7f68c..5869313 100644 --- a/tests/e2e/test_release_commands.py +++ b/tests/e2e/test_release_commands.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ End-to-end style integration tests for the `pkgmgr release` CLI command. @@ -141,8 +140,8 @@ class TestIntegrationReleaseCommand(unittest.TestCase): This test intentionally does not mock anything to exercise the real CLI parser wiring in main.py. """ - import io import contextlib + import io original_argv = list(sys.argv) buf = io.StringIO() diff --git a/tests/e2e/test_tools_commands.py b/tests/e2e/test_tools_commands.py index e134ce5..0886e0a 100644 --- a/tests/e2e/test_tools_commands.py +++ b/tests/e2e/test_tools_commands.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ Integration tests for the "tools" commands: diff --git a/tests/e2e/test_update_all_no_system.py b/tests/e2e/test_update_all_no_system.py index ac654b5..fca0dd3 100644 --- a/tests/e2e/test_update_all_no_system.py +++ b/tests/e2e/test_update_all_no_system.py @@ -22,8 +22,8 @@ from pathlib import Path from test_install_pkgmgr_shallow import ( nix_profile_list_debug, - remove_pkgmgr_from_nix_profile, pkgmgr_help_debug, + remove_pkgmgr_from_nix_profile, ) diff --git a/tests/e2e/test_update_pkgmgr_system.py b/tests/e2e/test_update_pkgmgr_system.py index 6aeb89e..825a5b2 100644 --- a/tests/e2e/test_update_pkgmgr_system.py +++ b/tests/e2e/test_update_pkgmgr_system.py @@ -21,8 +21,8 @@ from pathlib import Path from test_install_pkgmgr_shallow import ( nix_profile_list_debug, - remove_pkgmgr_from_nix_profile, pkgmgr_help_debug, + remove_pkgmgr_from_nix_profile, ) diff --git a/tests/e2e/test_version_commands.py b/tests/e2e/test_version_commands.py index d1eb09a..31fe14b 100644 --- a/tests/e2e/test_version_commands.py +++ b/tests/e2e/test_version_commands.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ End-to-end tests for the `pkgmgr version` command. diff --git a/tests/integration/test_branch_cli.py b/tests/integration/test_branch_cli.py index e3984af..95bd2fc 100644 --- a/tests/integration/test_branch_cli.py +++ b/tests/integration/test_branch_cli.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ Integration tests for the `pkgmgr branch` CLI wiring. @@ -16,8 +15,8 @@ from __future__ import annotations import unittest from unittest.mock import patch -from pkgmgr.cli.parser import create_parser from pkgmgr.cli.commands.branch import handle_branch +from pkgmgr.cli.parser import create_parser class TestBranchCLI(unittest.TestCase): diff --git a/tests/integration/test_config_defaults_integration.py b/tests/integration/test_config_defaults_integration.py index 43cc09f..33a61e0 100644 --- a/tests/integration/test_config_defaults_integration.py +++ b/tests/integration/test_config_defaults_integration.py @@ -11,8 +11,8 @@ from unittest.mock import patch import yaml -from pkgmgr.core.config.load import load_config from pkgmgr.cli.commands import config as config_cmd +from pkgmgr.core.config.load import load_config class ConfigDefaultsIntegrationTest(unittest.TestCase): diff --git a/tests/integration/test_install_repos.py b/tests/integration/test_install_repos.py index 28a9d03..1fe61c1 100644 --- a/tests/integration/test_install_repos.py +++ b/tests/integration/test_install_repos.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- import os import tempfile diff --git a/tests/integration/test_mirror_commands.py b/tests/integration/test_mirror_commands.py index 8265ed8..ff26d5f 100644 --- a/tests/integration/test_mirror_commands.py +++ b/tests/integration/test_mirror_commands.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ CLI integration tests for `pkgmgr mirror`. diff --git a/tests/integration/test_mirror_probe_detail_and_provision.py b/tests/integration/test_mirror_probe_detail_and_provision.py index 1e73b91..75dc39f 100644 --- a/tests/integration/test_mirror_probe_detail_and_provision.py +++ b/tests/integration/test_mirror_probe_detail_and_provision.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ Integration test for mirror probing + provisioning after refactor. diff --git a/tests/integration/test_recursive_capabilities.py b/tests/integration/test_recursive_capabilities.py index f4a4c9f..8927c57 100644 --- a/tests/integration/test_recursive_capabilities.py +++ b/tests/integration/test_recursive_capabilities.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ Integration tests for recursive capability resolution and installer shadowing. @@ -17,7 +16,8 @@ import os import shutil import tempfile import unittest -from typing import List, Sequence, Tuple +from collections.abc import Sequence +from typing import List, Tuple from unittest.mock import patch import pkgmgr.actions.install as install_mod @@ -29,7 +29,6 @@ from pkgmgr.actions.install.installers.os_packages.arch_pkgbuild import ( ) from pkgmgr.actions.install.installers.python import PythonInstaller - InstallerSpec = Tuple[str, object] diff --git a/tests/integration/test_update_silent_continues.py b/tests/integration/test_update_silent_continues.py index 3dfa492..8d8af1b 100644 --- a/tests/integration/test_update_silent_continues.py +++ b/tests/integration/test_update_silent_continues.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- from __future__ import annotations @@ -42,7 +41,6 @@ class TestUpdateSilentContinues(unittest.TestCase): pull_calls.append(repo["repository"]) if repo["repository"] == "repo-a": raise SystemExit(2) - return None def install_side_effect(selected_repos, *_args, **kwargs): repo = selected_repos[0] @@ -51,7 +49,6 @@ class TestUpdateSilentContinues(unittest.TestCase): ) if repo["repository"] == "repo-b": raise SystemExit(3) - return None # Patch at the exact import locations used inside UpdateManager.run() with ( diff --git a/tests/integration/test_visibility_integration.py b/tests/integration/test_visibility_integration.py index db8c50a..4156069 100644 --- a/tests/integration/test_visibility_integration.py +++ b/tests/integration/test_visibility_integration.py @@ -14,7 +14,6 @@ from pkgmgr.actions.mirror.setup_cmd import setup_mirrors from pkgmgr.actions.mirror.visibility_cmd import set_mirror_visibility from pkgmgr.core.remote_provisioning.types import RepoSpec - Repository = Dict[str, Any] diff --git a/tests/unit/pkgmgr/actions/branch/test_close_branch.py b/tests/unit/pkgmgr/actions/branch/test_close_branch.py index a764293..d0d8fae 100644 --- a/tests/unit/pkgmgr/actions/branch/test_close_branch.py +++ b/tests/unit/pkgmgr/actions/branch/test_close_branch.py @@ -2,8 +2,8 @@ import unittest from unittest.mock import patch from pkgmgr.actions.branch.close_branch import close_branch -from pkgmgr.core.git.errors import GitRunError from pkgmgr.core.git.commands import GitDeleteRemoteBranchError +from pkgmgr.core.git.errors import GitRunError class TestCloseBranch(unittest.TestCase): diff --git a/tests/unit/pkgmgr/actions/branch/test_drop_branch.py b/tests/unit/pkgmgr/actions/branch/test_drop_branch.py index 5b7e3b8..f694876 100644 --- a/tests/unit/pkgmgr/actions/branch/test_drop_branch.py +++ b/tests/unit/pkgmgr/actions/branch/test_drop_branch.py @@ -2,8 +2,8 @@ import unittest from unittest.mock import patch from pkgmgr.actions.branch.drop_branch import drop_branch -from pkgmgr.core.git.errors import GitRunError from pkgmgr.core.git.commands import GitDeleteRemoteBranchError +from pkgmgr.core.git.errors import GitRunError class TestDropBranch(unittest.TestCase): diff --git a/tests/unit/pkgmgr/actions/install/installers/nix/test_conflicts_resolver.py b/tests/unit/pkgmgr/actions/install/installers/nix/test_conflicts_resolver.py index 86b0efa..e22a38b 100644 --- a/tests/unit/pkgmgr/actions/install/installers/nix/test_conflicts_resolver.py +++ b/tests/unit/pkgmgr/actions/install/installers/nix/test_conflicts_resolver.py @@ -3,7 +3,8 @@ from __future__ import annotations import unittest from pkgmgr.actions.install.installers.nix.conflicts import NixConflictResolver -from ._fakes import FakeRunResult, FakeRunner, FakeRetry + +from ._fakes import FakeRetry, FakeRunner, FakeRunResult class DummyCtx: diff --git a/tests/unit/pkgmgr/actions/install/installers/nix/test_inspector.py b/tests/unit/pkgmgr/actions/install/installers/nix/test_inspector.py index 4e5633e..8345911 100644 --- a/tests/unit/pkgmgr/actions/install/installers/nix/test_inspector.py +++ b/tests/unit/pkgmgr/actions/install/installers/nix/test_inspector.py @@ -4,7 +4,8 @@ import json import unittest from pkgmgr.actions.install.installers.nix.profile import NixProfileInspector -from ._fakes import FakeRunResult, FakeRunner + +from ._fakes import FakeRunner, FakeRunResult class TestNixProfileInspector(unittest.TestCase): diff --git a/tests/unit/pkgmgr/actions/install/installers/nix/test_installer_core.py b/tests/unit/pkgmgr/actions/install/installers/nix/test_installer_core.py index a1a3361..fe2e357 100644 --- a/tests/unit/pkgmgr/actions/install/installers/nix/test_installer_core.py +++ b/tests/unit/pkgmgr/actions/install/installers/nix/test_installer_core.py @@ -4,6 +4,7 @@ import unittest from unittest.mock import MagicMock from pkgmgr.actions.install.installers.nix.installer import NixFlakeInstaller + from ._fakes import FakeRunResult diff --git a/tests/unit/pkgmgr/actions/install/installers/nix/test_legacy.py b/tests/unit/pkgmgr/actions/install/installers/nix/test_legacy.py index fb421dc..9595cda 100644 --- a/tests/unit/pkgmgr/actions/install/installers/nix/test_legacy.py +++ b/tests/unit/pkgmgr/actions/install/installers/nix/test_legacy.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ Unit tests for NixFlakeInstaller using unittest (no pytest). diff --git a/tests/unit/pkgmgr/actions/install/installers/nix/test_matcher.py b/tests/unit/pkgmgr/actions/install/installers/nix/test_matcher.py index ca33925..0c813b2 100644 --- a/tests/unit/pkgmgr/actions/install/installers/nix/test_matcher.py +++ b/tests/unit/pkgmgr/actions/install/installers/nix/test_matcher.py @@ -2,11 +2,11 @@ from __future__ import annotations import unittest -from pkgmgr.actions.install.installers.nix.profile.models import NixProfileEntry from pkgmgr.actions.install.installers.nix.profile.matcher import ( entry_matches_output, entry_matches_store_path, ) +from pkgmgr.actions.install.installers.nix.profile.models import NixProfileEntry class TestMatcher(unittest.TestCase): diff --git a/tests/unit/pkgmgr/actions/install/installers/nix/test_profile_list_reader.py b/tests/unit/pkgmgr/actions/install/installers/nix/test_profile_list_reader.py index 3529572..73e29ab 100644 --- a/tests/unit/pkgmgr/actions/install/installers/nix/test_profile_list_reader.py +++ b/tests/unit/pkgmgr/actions/install/installers/nix/test_profile_list_reader.py @@ -3,7 +3,8 @@ from __future__ import annotations import unittest from pkgmgr.actions.install.installers.nix.profile_list import NixProfileListReader -from ._fakes import FakeRunResult, FakeRunner + +from ._fakes import FakeRunner, FakeRunResult class TestNixProfileListReader(unittest.TestCase): diff --git a/tests/unit/pkgmgr/actions/install/installers/test_base.py b/tests/unit/pkgmgr/actions/install/installers/test_base.py index 6835de2..6435634 100644 --- a/tests/unit/pkgmgr/actions/install/installers/test_base.py +++ b/tests/unit/pkgmgr/actions/install/installers/test_base.py @@ -1,8 +1,9 @@ # tests/unit/pkgmgr/installers/test_base.py import unittest -from pkgmgr.actions.install.installers.base import BaseInstaller + from pkgmgr.actions.install.context import RepoContext +from pkgmgr.actions.install.installers.base import BaseInstaller class DummyInstaller(BaseInstaller): diff --git a/tests/unit/pkgmgr/actions/install/installers/test_makefile_installer.py b/tests/unit/pkgmgr/actions/install/installers/test_makefile_installer.py index 3f2e638..a6f96ec 100644 --- a/tests/unit/pkgmgr/actions/install/installers/test_makefile_installer.py +++ b/tests/unit/pkgmgr/actions/install/installers/test_makefile_installer.py @@ -2,7 +2,7 @@ import os import unittest -from unittest.mock import patch, mock_open +from unittest.mock import mock_open, patch from pkgmgr.actions.install.context import RepoContext from pkgmgr.actions.install.installers.makefile import MakefileInstaller diff --git a/tests/unit/pkgmgr/actions/install/test_capabilities.py b/tests/unit/pkgmgr/actions/install/test_capabilities.py index 44b59d3..ddeaf50 100644 --- a/tests/unit/pkgmgr/actions/install/test_capabilities.py +++ b/tests/unit/pkgmgr/actions/install/test_capabilities.py @@ -1,16 +1,16 @@ # tests/unit/pkgmgr/test_capabilities.py import unittest -from unittest.mock import patch, mock_open +from unittest.mock import mock_open, patch from pkgmgr.actions.install.capabilities import ( - PythonRuntimeCapability, + LAYER_ORDER, + CapabilityMatcher, MakeInstallCapability, NixFlakeCapability, - CapabilityMatcher, + PythonRuntimeCapability, detect_capabilities, resolve_effective_capabilities, - LAYER_ORDER, ) diff --git a/tests/unit/pkgmgr/actions/install/test_context.py b/tests/unit/pkgmgr/actions/install/test_context.py index af57607..d950801 100644 --- a/tests/unit/pkgmgr/actions/install/test_context.py +++ b/tests/unit/pkgmgr/actions/install/test_context.py @@ -1,4 +1,5 @@ import unittest + from pkgmgr.actions.install.context import RepoContext diff --git a/tests/unit/pkgmgr/actions/install/test_install_repos.py b/tests/unit/pkgmgr/actions/install/test_install_repos.py index 1c4f043..ee785d4 100644 --- a/tests/unit/pkgmgr/actions/install/test_install_repos.py +++ b/tests/unit/pkgmgr/actions/install/test_install_repos.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- import os import unittest @@ -8,7 +7,6 @@ from unittest.mock import MagicMock, patch from pkgmgr.actions.install import install_repos - Repository = Dict[str, Any] diff --git a/tests/unit/pkgmgr/actions/install/test_layers.py b/tests/unit/pkgmgr/actions/install/test_layers.py index 28d385f..b7f58c4 100644 --- a/tests/unit/pkgmgr/actions/install/test_layers.py +++ b/tests/unit/pkgmgr/actions/install/test_layers.py @@ -1,12 +1,11 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- import os import unittest from pkgmgr.actions.install.layers import ( - CliLayer, CLI_LAYERS, + CliLayer, classify_command_layer, layer_priority, ) diff --git a/tests/unit/pkgmgr/actions/install/test_pipeline.py b/tests/unit/pkgmgr/actions/install/test_pipeline.py index 233cd15..c3d34c4 100644 --- a/tests/unit/pkgmgr/actions/install/test_pipeline.py +++ b/tests/unit/pkgmgr/actions/install/test_pipeline.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- import unittest from unittest.mock import MagicMock, patch diff --git a/tests/unit/pkgmgr/actions/mirror/test_context.py b/tests/unit/pkgmgr/actions/mirror/test_context.py index cd17d8c..9e0c38e 100644 --- a/tests/unit/pkgmgr/actions/mirror/test_context.py +++ b/tests/unit/pkgmgr/actions/mirror/test_context.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- from __future__ import annotations diff --git a/tests/unit/pkgmgr/actions/mirror/test_diff_cmd.py b/tests/unit/pkgmgr/actions/mirror/test_diff_cmd.py index 12a75a2..2fc28f2 100644 --- a/tests/unit/pkgmgr/actions/mirror/test_diff_cmd.py +++ b/tests/unit/pkgmgr/actions/mirror/test_diff_cmd.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- from __future__ import annotations diff --git a/tests/unit/pkgmgr/actions/mirror/test_git_remote_primary_push.py b/tests/unit/pkgmgr/actions/mirror/test_git_remote_primary_push.py index 1a27c55..5bb9ba4 100644 --- a/tests/unit/pkgmgr/actions/mirror/test_git_remote_primary_push.py +++ b/tests/unit/pkgmgr/actions/mirror/test_git_remote_primary_push.py @@ -22,25 +22,24 @@ class TestGitRemotePrimaryPush(unittest.TestCase): }, ) - with patch("os.path.isdir", return_value=True): - with ( - patch( - "pkgmgr.actions.mirror.git_remote.has_origin_remote", - return_value=False, - ), - patch("pkgmgr.actions.mirror.git_remote.add_remote") as m_add_remote, - patch( - "pkgmgr.actions.mirror.git_remote.set_remote_url" - ) as m_set_remote_url, - patch( - "pkgmgr.actions.mirror.git_remote.get_remote_push_urls", - return_value=set(), - ), - patch( - "pkgmgr.actions.mirror.git_remote.add_remote_push_url" - ) as m_add_push, - ): - ensure_origin_remote(repo, ctx, preview=False) + with ( + patch("os.path.isdir", return_value=True), patch( + "pkgmgr.actions.mirror.git_remote.has_origin_remote", + return_value=False, + ), + patch("pkgmgr.actions.mirror.git_remote.add_remote") as m_add_remote, + patch( + "pkgmgr.actions.mirror.git_remote.set_remote_url" + ) as m_set_remote_url, + patch( + "pkgmgr.actions.mirror.git_remote.get_remote_push_urls", + return_value=set(), + ), + patch( + "pkgmgr.actions.mirror.git_remote.add_remote_push_url" + ) as m_add_push, + ): + ensure_origin_remote(repo, ctx, preview=False) # determine_primary_remote_url falls back to file order (primary first) m_add_remote.assert_called_once_with( diff --git a/tests/unit/pkgmgr/actions/mirror/test_io.py b/tests/unit/pkgmgr/actions/mirror/test_io.py index 19b01c8..4fba34f 100644 --- a/tests/unit/pkgmgr/actions/mirror/test_io.py +++ b/tests/unit/pkgmgr/actions/mirror/test_io.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- from __future__ import annotations diff --git a/tests/unit/pkgmgr/actions/mirror/test_list_cmd.py b/tests/unit/pkgmgr/actions/mirror/test_list_cmd.py index 71f7d59..f0ac9fd 100644 --- a/tests/unit/pkgmgr/actions/mirror/test_list_cmd.py +++ b/tests/unit/pkgmgr/actions/mirror/test_list_cmd.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- from __future__ import annotations diff --git a/tests/unit/pkgmgr/actions/mirror/test_remote_provision.py b/tests/unit/pkgmgr/actions/mirror/test_remote_provision.py index 333162b..1ce0567 100644 --- a/tests/unit/pkgmgr/actions/mirror/test_remote_provision.py +++ b/tests/unit/pkgmgr/actions/mirror/test_remote_provision.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- from __future__ import annotations diff --git a/tests/unit/pkgmgr/actions/mirror/test_url_utils.py b/tests/unit/pkgmgr/actions/mirror/test_url_utils.py index 2e74a06..3b1832b 100644 --- a/tests/unit/pkgmgr/actions/mirror/test_url_utils.py +++ b/tests/unit/pkgmgr/actions/mirror/test_url_utils.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- from __future__ import annotations diff --git a/tests/unit/pkgmgr/actions/mirror/test_visibility_cmd.py b/tests/unit/pkgmgr/actions/mirror/test_visibility_cmd.py index e76e352..e1877a2 100644 --- a/tests/unit/pkgmgr/actions/mirror/test_visibility_cmd.py +++ b/tests/unit/pkgmgr/actions/mirror/test_visibility_cmd.py @@ -4,7 +4,7 @@ from __future__ import annotations import io import unittest from contextlib import redirect_stdout -from unittest.mock import patch, MagicMock +from unittest.mock import MagicMock, patch from pkgmgr.actions.mirror.visibility_cmd import set_mirror_visibility diff --git a/tests/unit/pkgmgr/actions/publish/test_pypi_url.py b/tests/unit/pkgmgr/actions/publish/test_pypi_url.py index 77b874f..5a9c46c 100644 --- a/tests/unit/pkgmgr/actions/publish/test_pypi_url.py +++ b/tests/unit/pkgmgr/actions/publish/test_pypi_url.py @@ -1,4 +1,5 @@ import unittest + from pkgmgr.actions.publish.pypi_url import parse_pypi_project_url diff --git a/tests/unit/pkgmgr/actions/release/test_init.py b/tests/unit/pkgmgr/actions/release/test_init.py index 7fe52ab..7281e5a 100644 --- a/tests/unit/pkgmgr/actions/release/test_init.py +++ b/tests/unit/pkgmgr/actions/release/test_init.py @@ -5,7 +5,7 @@ import unittest class TestReleasePackageInit(unittest.TestCase): def test_release_is_reexported(self) -> None: - from pkgmgr.actions.release import release # noqa: F401 + from pkgmgr.actions.release import release self.assertTrue(callable(release)) diff --git a/tests/unit/pkgmgr/actions/release/test_versioning.py b/tests/unit/pkgmgr/actions/release/test_versioning.py index f63a8c0..adf09e2 100644 --- a/tests/unit/pkgmgr/actions/release/test_versioning.py +++ b/tests/unit/pkgmgr/actions/release/test_versioning.py @@ -3,11 +3,11 @@ from __future__ import annotations import unittest from unittest.mock import patch -from pkgmgr.core.version.semver import SemVer from pkgmgr.actions.release.versioning import ( - determine_current_version, bump_semver, + determine_current_version, ) +from pkgmgr.core.version.semver import SemVer class TestDetermineCurrentVersion(unittest.TestCase): diff --git a/tests/unit/pkgmgr/actions/repository/create/test_create_parsing.py b/tests/unit/pkgmgr/actions/repository/create/test_create_parsing.py index d59b61a..cb886b3 100644 --- a/tests/unit/pkgmgr/actions/repository/create/test_create_parsing.py +++ b/tests/unit/pkgmgr/actions/repository/create/test_create_parsing.py @@ -4,10 +4,10 @@ import unittest from pkgmgr.actions.repository.create.model import RepoParts from pkgmgr.actions.repository.create.parser import ( - parse_identifier, _parse_git_url, - _strip_git_suffix, _split_host_port, + _strip_git_suffix, + parse_identifier, ) diff --git a/tests/unit/pkgmgr/actions/test_changelog.py b/tests/unit/pkgmgr/actions/test_changelog.py index 338ee19..056af35 100644 --- a/tests/unit/pkgmgr/actions/test_changelog.py +++ b/tests/unit/pkgmgr/actions/test_changelog.py @@ -4,8 +4,8 @@ import unittest from unittest.mock import patch from pkgmgr.actions.changelog import generate_changelog -from pkgmgr.core.git.queries import GitChangelogQueryError from pkgmgr.cli.commands.changelog import _find_previous_and_current_tag +from pkgmgr.core.git.queries import GitChangelogQueryError class TestGenerateChangelog(unittest.TestCase): diff --git a/tests/unit/pkgmgr/cli/commands/test_release.py b/tests/unit/pkgmgr/cli/commands/test_release.py index 111a00b..522e524 100644 --- a/tests/unit/pkgmgr/cli/commands/test_release.py +++ b/tests/unit/pkgmgr/cli/commands/test_release.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ Unit tests for pkgmgr.cli.commands.release. @@ -14,12 +13,11 @@ These tests focus on the wiring layer: from __future__ import annotations -from types import SimpleNamespace -from typing import List -from unittest.mock import patch, call - import argparse import unittest +from types import SimpleNamespace +from typing import List +from unittest.mock import call, patch class TestReleaseCommand(unittest.TestCase): diff --git a/tests/unit/pkgmgr/cli/commands/test_repos.py b/tests/unit/pkgmgr/cli/commands/test_repos.py index 029f420..2f32a21 100644 --- a/tests/unit/pkgmgr/cli/commands/test_repos.py +++ b/tests/unit/pkgmgr/cli/commands/test_repos.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ Unit tests for pkgmgr.cli.commands.repos @@ -30,9 +29,8 @@ from types import SimpleNamespace from typing import Any, Dict, List from unittest.mock import patch -from pkgmgr.cli.context import CLIContext from pkgmgr.cli.commands.repos import handle_repos_command - +from pkgmgr.cli.context import CLIContext Repository = Dict[str, Any] diff --git a/tests/unit/pkgmgr/cli/test_cli.py b/tests/unit/pkgmgr/cli/test_cli.py index 4dac13f..5755fa5 100644 --- a/tests/unit/pkgmgr/cli/test_cli.py +++ b/tests/unit/pkgmgr/cli/test_cli.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ Unit tests for the pkgmgr CLI (version command). diff --git a/tests/unit/pkgmgr/cli/tools/test_vscode.py b/tests/unit/pkgmgr/cli/tools/test_vscode.py index 98f4d87..18d5803 100644 --- a/tests/unit/pkgmgr/cli/tools/test_vscode.py +++ b/tests/unit/pkgmgr/cli/tools/test_vscode.py @@ -54,9 +54,9 @@ class TestOpenVSCodeWorkspace(unittest.TestCase): "pkgmgr.cli.tools.vscode.get_repo_identifier", return_value="github.com/x/y", ), + self.assertRaises(RuntimeError) as cm, ): - with self.assertRaises(RuntimeError) as cm: - open_vscode_workspace(ctx, selected) + open_vscode_workspace(ctx, selected) msg = str(cm.exception) self.assertIn("not yet identified", msg) diff --git a/tests/unit/pkgmgr/core/command/test_resolve.py b/tests/unit/pkgmgr/core/command/test_resolve.py index dcf3967..17828b4 100644 --- a/tests/unit/pkgmgr/core/command/test_resolve.py +++ b/tests/unit/pkgmgr/core/command/test_resolve.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- import os import stat diff --git a/tests/unit/pkgmgr/core/config/test_cli_update.py b/tests/unit/pkgmgr/core/config/test_cli_update.py index 5b60334..c535ede 100644 --- a/tests/unit/pkgmgr/core/config/test_cli_update.py +++ b/tests/unit/pkgmgr/core/config/test_cli_update.py @@ -82,9 +82,8 @@ class UpdateDefaultConfigsTests(unittest.TestCase): # Patch the source dir finder to our temp source_dir with patch.object( config_cmd, "_find_defaults_source_dir", return_value=str(source_dir) - ): - with patch.dict(os.environ, {"HOME": str(home)}): - config_cmd._update_default_configs(user_config_path) + ), patch.dict(os.environ, {"HOME": str(home)}): + config_cmd._update_default_configs(user_config_path) self.assertTrue((dest_cfg_dir / "a.yaml").is_file()) self.assertTrue((dest_cfg_dir / "b.yml").is_file()) @@ -102,9 +101,8 @@ class UpdateDefaultConfigsTests(unittest.TestCase): with patch.object( config_cmd, "_find_defaults_source_dir", return_value=str(source_dir) - ): - with patch.dict(os.environ, {"HOME": str(home)}): - config_cmd._update_default_configs(user_config_path) + ), patch.dict(os.environ, {"HOME": str(home)}): + config_cmd._update_default_configs(user_config_path) self.assertEqual( (dest_cfg_dir / "config.yaml").read_text(encoding="utf-8"), @@ -122,10 +120,8 @@ class UpdateDefaultConfigsTests(unittest.TestCase): buf = io.StringIO() with patch.object( config_cmd, "_find_defaults_source_dir", return_value=None - ): - with patch("sys.stdout", buf): - with patch.dict(os.environ, {"HOME": str(home)}): - config_cmd._update_default_configs(user_config_path) + ), patch("sys.stdout", buf), patch.dict(os.environ, {"HOME": str(home)}): + config_cmd._update_default_configs(user_config_path) out = buf.getvalue() self.assertIn("[WARN] No config directory found", out) diff --git a/tests/unit/pkgmgr/core/config/test_load.py b/tests/unit/pkgmgr/core/config/test_load.py index aaa3f30..4dfb98b 100644 --- a/tests/unit/pkgmgr/core/config/test_load.py +++ b/tests/unit/pkgmgr/core/config/test_load.py @@ -12,9 +12,9 @@ import yaml from pkgmgr.core.config.load import ( _deep_merge, - _merge_repo_lists, - _load_layer_dir, _load_defaults_from_package_or_project, + _load_layer_dir, + _merge_repo_lists, load_config, ) diff --git a/tests/unit/pkgmgr/core/git/queries/test_get_latest_signing_key.py b/tests/unit/pkgmgr/core/git/queries/test_get_latest_signing_key.py index f770519..7106040 100644 --- a/tests/unit/pkgmgr/core/git/queries/test_get_latest_signing_key.py +++ b/tests/unit/pkgmgr/core/git/queries/test_get_latest_signing_key.py @@ -1,5 +1,5 @@ -import unittest import subprocess +import unittest from unittest.mock import patch from pkgmgr.core.git.errors import GitNotRepositoryError diff --git a/tests/unit/pkgmgr/core/git/queries/test_remote_check.py b/tests/unit/pkgmgr/core/git/queries/test_remote_check.py index 17b13c0..fe89eb7 100644 --- a/tests/unit/pkgmgr/core/git/queries/test_remote_check.py +++ b/tests/unit/pkgmgr/core/git/queries/test_remote_check.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- from __future__ import annotations diff --git a/tests/unit/pkgmgr/core/remote_provisioning/test_visibility.py b/tests/unit/pkgmgr/core/remote_provisioning/test_visibility.py index 064af5c..c2f2ca4 100644 --- a/tests/unit/pkgmgr/core/remote_provisioning/test_visibility.py +++ b/tests/unit/pkgmgr/core/remote_provisioning/test_visibility.py @@ -4,6 +4,7 @@ from __future__ import annotations import unittest from unittest.mock import MagicMock +from pkgmgr.core.remote_provisioning.http.errors import HttpError from pkgmgr.core.remote_provisioning.types import ( AuthError, NetworkError, @@ -16,7 +17,6 @@ from pkgmgr.core.remote_provisioning.visibility import ( VisibilityOptions, set_repo_visibility, ) -from pkgmgr.core.remote_provisioning.http.errors import HttpError class TestSetRepoVisibility(unittest.TestCase): diff --git a/tests/unit/pkgmgr/core/repository/test_ignored.py b/tests/unit/pkgmgr/core/repository/test_ignored.py index df16144..8255b13 100644 --- a/tests/unit/pkgmgr/core/repository/test_ignored.py +++ b/tests/unit/pkgmgr/core/repository/test_ignored.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- import unittest diff --git a/tests/unit/pkgmgr/core/repository/test_selected.py b/tests/unit/pkgmgr/core/repository/test_selected.py index 079877f..66a39c6 100644 --- a/tests/unit/pkgmgr/core/repository/test_selected.py +++ b/tests/unit/pkgmgr/core/repository/test_selected.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- import os import unittest diff --git a/tests/unit/pkgmgr/core/repository/test_verify_repository.py b/tests/unit/pkgmgr/core/repository/test_verify_repository.py index 23dd774..64af9be 100644 --- a/tests/unit/pkgmgr/core/repository/test_verify_repository.py +++ b/tests/unit/pkgmgr/core/repository/test_verify_repository.py @@ -118,6 +118,5 @@ class TestVerifyRepository(unittest.TestCase): with patch( "pkgmgr.core.repository.verify.get_head_commit", side_effect=GitNotRepositoryError("no repo"), - ): - with self.assertRaises(GitNotRepositoryError): - verify_repository(repo, "/tmp/no-repo", mode="local") + ), self.assertRaises(GitNotRepositoryError): + verify_repository(repo, "/tmp/no-repo", mode="local") diff --git a/tests/unit/pkgmgr/core/test_create_ink.py b/tests/unit/pkgmgr/core/test_create_ink.py index 0849135..4ff7605 100644 --- a/tests/unit/pkgmgr/core/test_create_ink.py +++ b/tests/unit/pkgmgr/core/test_create_ink.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- import unittest from unittest.mock import patch diff --git a/tests/unit/pkgmgr/core/test_git_utils.py b/tests/unit/pkgmgr/core/test_git_utils.py index 34be761..5884a93 100644 --- a/tests/unit/pkgmgr/core/test_git_utils.py +++ b/tests/unit/pkgmgr/core/test_git_utils.py @@ -1,12 +1,11 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- import unittest from unittest.mock import patch from pkgmgr.core.git.errors import GitRunError +from pkgmgr.core.git.queries import get_current_branch, get_head_commit, get_tags from pkgmgr.core.git.run import run -from pkgmgr.core.git.queries import get_tags, get_head_commit, get_current_branch class TestGitRun(unittest.TestCase): diff --git a/tests/unit/pkgmgr/core/test_versioning.py b/tests/unit/pkgmgr/core/test_versioning.py index c65edd8..a72a2cd 100644 --- a/tests/unit/pkgmgr/core/test_versioning.py +++ b/tests/unit/pkgmgr/core/test_versioning.py @@ -1,16 +1,15 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- import unittest from pkgmgr.core.version.semver import ( SemVer, - is_semver_tag, - extract_semver_from_tags, - find_latest_version, bump_major, bump_minor, bump_patch, + extract_semver_from_tags, + find_latest_version, + is_semver_tag, ) @@ -30,9 +29,8 @@ class TestSemVer(unittest.TestCase): def test_semver_parse_invalid(self): invalid_values = ["", "1", "1.2", "1.2.3.4", "a.b.c", "v1.2.x"] for value in invalid_values: - with self.subTest(value=value): - with self.assertRaises(ValueError): - SemVer.parse(value) + with self.subTest(value=value), self.assertRaises(ValueError): + SemVer.parse(value) def test_semver_to_tag_and_str(self): ver = SemVer(1, 2, 3)