style: modernise typing and clean up lint findings
Repository-wide mechanical cleanup so `ruff check src tests` has a chance of passing; no behavioural changes. - Add `from __future__ import annotations` where PEP 604 unions are used. This has to come first: pyproject declares requires-python >= 3.9, where `X | None` is not evaluable at runtime unless annotations are stringified. - Replace typing.List/Dict/Tuple/Set with the builtin generics and Optional[X] with X | None, then drop the imports that became unused. The four actions/*/__init__.py files needed this by hand because ruff leaves unused imports in __init__.py alone (possible re-exports). - Strip shebangs from 72 importable modules. None of them are executable or invoked directly; the entry points are console_scripts and runpy. - Flatten nested `with` blocks, collapse needless-bool returns, and apply the remaining mechanical ruff fixes (PIE810, FLY002, PERF102, FURB192, RUF059, I001). - Pass check=False explicitly to the four subprocess.run() calls that inspect returncode themselves. That is the existing default. Two rewrites are visible to mocks, so their tests move with them: subprocess.run(stdout=PIPE, stderr=PIPE) became capture_output=True, and open(path, "r", ...) lost the redundant mode. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""
|
||||
Integration tests for recursive capability resolution and installer shadowing.
|
||||
|
||||
@@ -17,7 +15,6 @@ import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
from collections.abc import Sequence
|
||||
from typing import List, Tuple
|
||||
from unittest.mock import patch
|
||||
|
||||
import pkgmgr.actions.install as install_mod
|
||||
@@ -29,7 +26,7 @@ from pkgmgr.actions.install.installers.os_packages.arch_pkgbuild import (
|
||||
)
|
||||
from pkgmgr.actions.install.installers.python import PythonInstaller
|
||||
|
||||
InstallerSpec = Tuple[str, object]
|
||||
InstallerSpec = tuple[str, object]
|
||||
|
||||
|
||||
class TestRecursiveCapabilitiesIntegration(unittest.TestCase):
|
||||
@@ -54,7 +51,7 @@ class TestRecursiveCapabilitiesIntegration(unittest.TestCase):
|
||||
repo_dir: str,
|
||||
installers: Sequence[InstallerSpec],
|
||||
selected_repos=None,
|
||||
) -> List[str]:
|
||||
) -> list[str]:
|
||||
"""
|
||||
Run install_repos() with a custom INSTALLERS list and capture which
|
||||
installer labels actually run.
|
||||
@@ -69,7 +66,7 @@ class TestRecursiveCapabilitiesIntegration(unittest.TestCase):
|
||||
else:
|
||||
all_repos = selected_repos
|
||||
|
||||
called_installers: List[str] = []
|
||||
called_installers: list[str] = []
|
||||
|
||||
patched_installers = []
|
||||
for label, inst in installers:
|
||||
|
||||
Reference in New Issue
Block a user