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:
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -4,6 +4,7 @@ import unittest
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from pkgmgr.actions.install.installers.nix.installer import NixFlakeInstaller
|
||||
|
||||
from ._fakes import FakeRunResult
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Unit tests for NixFlakeInstaller using unittest (no pytest).
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import unittest
|
||||
|
||||
from pkgmgr.actions.install.context import RepoContext
|
||||
|
||||
|
||||
|
||||
@@ -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]
|
||||
|
||||
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import unittest
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import unittest
|
||||
|
||||
from pkgmgr.actions.publish.pypi_url import parse_pypi_project_url
|
||||
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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]
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Unit tests for the pkgmgr CLI (version command).
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import stat
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import unittest
|
||||
import subprocess
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from pkgmgr.core.git.errors import GitNotRepositoryError
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import unittest
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user