style: autoformat src and tests

Repository-wide formatting pass over src/ and tests/: sorted imports and
__all__ entries, dropped redundant `# -*- coding: utf-8 -*-` headers,
unquoted forward-reference annotations (safe under
`from __future__ import annotations`), merged nested `with` statements,
moved `Iterable` and friends from `typing` to `collections.abc`, and
removed `# noqa: F401` markers that no longer suppress anything.

No behavioural changes. Unit and integration suites show the same four
pre-existing failures before and after the pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-Birkenbach
2026-07-27 15:17:35 +02:00
parent f1517963a5
commit 8294bce436
185 changed files with 378 additions and 445 deletions

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Top-level pkgmgr package.

View File

@@ -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"]

View File

@@ -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"

View File

@@ -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",
]

View File

@@ -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(

View File

@@ -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(

View File

@@ -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,
)

View File

@@ -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)

View File

@@ -1,5 +1,7 @@
import yaml
import os
import yaml
from pkgmgr.core.config.save import save_user_config

View File

@@ -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

View File

@@ -1,4 +1,5 @@
import yaml
from pkgmgr.core.config.load import load_config

View File

@@ -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]

View File

@@ -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]]:
"""

View File

@@ -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

View File

@@ -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):

View File

@@ -33,7 +33,7 @@ class NixConflictResolver:
def resolve(
self,
ctx: "RepoContext",
ctx: RepoContext,
install_cmd: str,
stdout: str,
stderr: str,

View File

@@ -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

View File

@@ -1,4 +1,4 @@
from .inspector import NixProfileInspector
from .models import NixProfileEntry
__all__ = ["NixProfileInspector", "NixProfileEntry"]
__all__ = ["NixProfileEntry", "NixProfileInspector"]

View File

@@ -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]:
"""

View File

@@ -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

View File

@@ -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]

View File

@@ -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))

View File

@@ -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))

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Installer for Debian/Ubuntu packages defined via debian/control.

View File

@@ -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(

View File

@@ -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

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
CLI layer model for the pkgmgr installation pipeline.

View File

@@ -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

View File

@@ -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",
]

View File

@@ -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

View File

@@ -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
# -----------------------------------------------------------------------------

View File

@@ -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]]:

View File

@@ -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,

View File

@@ -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",
]

View File

@@ -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)

View File

@@ -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,
)

View File

@@ -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

View File

@@ -1,7 +1,7 @@
from __future__ import annotations
import os
from typing import Dict, Any, Set
from typing import Any, Dict, Set
import yaml

View File

@@ -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:

View File

@@ -1,7 +1,7 @@
from __future__ import annotations
import os
from typing import Dict, Any
from typing import Any, Dict
from .model import RepoParts

View File

@@ -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:

View File

@@ -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

View File

@@ -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):

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Pretty-print repository list with status, categories, tags and path.

View File

@@ -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]

View File

@@ -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]

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import annotations

View File

@@ -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

View File

@@ -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(),

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import annotations

View File

@@ -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"]

View File

@@ -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",
]

View File

@@ -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:

View File

@@ -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]

View File

@@ -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]:

View File

@@ -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]

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import annotations

View File

@@ -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

View File

@@ -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]

View File

@@ -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:

View File

@@ -74,4 +74,4 @@ def create_parser(description_text: str) -> argparse.ArgumentParser:
return parser
__all__ = ["create_parser", "SortedSubParsersAction"]
__all__ = ["SortedSubParsersAction", "create_parser"]

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import annotations

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import annotations

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import annotations

View File

@@ -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,
)

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import annotations

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import annotations

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import annotations

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import annotations

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import annotations

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import annotations

View File

@@ -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": [

View File

@@ -1,5 +1,5 @@
import os
import hashlib
import os
import re

View File

@@ -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(

View File

@@ -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]

View File

@@ -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."""

View File

@@ -10,11 +10,11 @@ from .types import (
)
__all__ = [
"TokenResolver",
"ResolutionOptions",
"CredentialError",
"NoCredentialsError",
"KeyringUnavailableError",
"NoCredentialsError",
"ResolutionOptions",
"TokenRequest",
"TokenResolver",
"TokenResult",
]

View File

@@ -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",
]

View File

@@ -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

View File

@@ -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,

View File

@@ -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:

View File

@@ -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",
]

View File

@@ -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

View File

@@ -1,6 +1,6 @@
from __future__ import annotations
from ..errors import GitRunError, GitCommandError
from ..errors import GitCommandError, GitRunError
from ..run import run

View File

@@ -1,6 +1,6 @@
from __future__ import annotations
from ..errors import GitRunError, GitCommandError
from ..errors import GitCommandError, GitRunError
from ..run import run

View File

@@ -1,6 +1,6 @@
from __future__ import annotations
from ..errors import GitRunError, GitCommandError
from ..errors import GitCommandError, GitRunError
from ..run import run

View File

@@ -1,6 +1,6 @@
from __future__ import annotations
from ..errors import GitRunError, GitCommandError
from ..errors import GitCommandError, GitRunError
from ..run import run

View File

@@ -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

View File

@@ -1,6 +1,6 @@
from __future__ import annotations
from ..errors import GitRunError, GitCommandError
from ..errors import GitCommandError, GitRunError
from ..run import run

View File

@@ -1,6 +1,6 @@
from __future__ import annotations
from ..errors import GitRunError, GitCommandError
from ..errors import GitCommandError, GitRunError
from ..run import run

View File

@@ -1,6 +1,6 @@
from __future__ import annotations
from ..errors import GitRunError, GitCommandError
from ..errors import GitCommandError, GitRunError
from ..run import run

View File

@@ -1,6 +1,6 @@
from __future__ import annotations
from ..errors import GitRunError, GitCommandError
from ..errors import GitCommandError, GitRunError
from ..run import run

View File

@@ -1,6 +1,6 @@
from __future__ import annotations
from ..errors import GitRunError, GitCommandError
from ..errors import GitCommandError, GitRunError
from ..run import run

View File

@@ -1,6 +1,6 @@
from __future__ import annotations
from ..errors import GitRunError, GitCommandError
from ..errors import GitCommandError, GitRunError
from ..run import run

View File

@@ -1,6 +1,6 @@
from __future__ import annotations
from ..errors import GitRunError, GitCommandError
from ..errors import GitCommandError, GitRunError
from ..run import run

View File

@@ -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

View File

@@ -1,6 +1,6 @@
from __future__ import annotations
from ..errors import GitRunError, GitCommandError
from ..errors import GitCommandError, GitRunError
from ..run import run

View File

@@ -1,6 +1,6 @@
from __future__ import annotations
from ..errors import GitRunError, GitCommandError
from ..errors import GitCommandError, GitRunError
from ..run import run

View File

@@ -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

View File

@@ -1,6 +1,6 @@
from __future__ import annotations
from ..errors import GitRunError, GitCommandError
from ..errors import GitCommandError, GitRunError
from ..run import run

Some files were not shown because too many files have changed in this diff Show More