pyproject.toml: Enforce import annotations style

Add new ruff rules and fix their fallout:

future-annotations = true

select = [ "TC", # type-checking import placement rules "FA", # future annotations rules ]

This comprises:

- Streamline imports and exports in cmds.xxx.Cmd

- Import base class as "Base"
- Export types Cmd and Parent via __all__

- Move all types imported only for annotation below TYPE_CHECKING

- Use "from __future__ import annotations" all over the place

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-06-01 10:04:38 +02:00
commit 5d1ba6e15a
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61
77 changed files with 382 additions and 196 deletions

View file

@ -38,10 +38,14 @@
[tool.ruff.lint]
future-annotations = true
select = [
"F", # Pyflakes, includes F401
"E", # pycodestyle errors
"W", # pycodestyle warnings
"TC", # type-checking import placement rules
"FA", # future annotations rules
]
ignore = [

View file

@ -4,7 +4,6 @@
from __future__ import annotations
import argparse
import os
import pwd
import re
@ -19,10 +18,7 @@ from .lib.Distro import Distro
from .lib.log import DEBUG, ERR, log
if TYPE_CHECKING:
import os
import pwd
import re
import sys
import argparse
from typing import TypeAlias

View file

@ -2,15 +2,15 @@ from __future__ import annotations
from typing import TYPE_CHECKING
from ..CmdBase import CmdBase
from ..App import App as Parent
from ..CmdBase import CmdBase as Base
if TYPE_CHECKING:
from ..App import App
from ..lib.Distro import Distro
class Cmd(CmdBase): # export
class Cmd(Base): # export
def __init__(self, parent: App | CmdBase, name: str, help: str) -> None:
def __init__(self, parent: Parent, name: str, help: str) -> None:
super().__init__(parent, name, help)
async def _run(self, args):
@ -20,3 +20,5 @@ class Cmd(CmdBase): # export
@property
def distro(self) -> Distro:
return self.app.distro
__all__ = ['Parent', 'Cmd']

View file

@ -1,11 +1,15 @@
from argparse import ArgumentParser
from __future__ import annotations
from ..App import App
from .Cmd import Cmd as CmdBase
from typing import TYPE_CHECKING
class CmdPkg(CmdBase): # export
from .Cmd import Cmd, Parent
def __init__(self, parent: App) -> None:
if TYPE_CHECKING:
from argparse import ArgumentParser
class CmdPkg(Cmd): # export
def __init__(self, parent: Parent) -> None:
super().__init__(parent, 'pkg', help = 'System package manager wrapper')
self.load_subcommands()

View file

@ -1,11 +1,15 @@
from argparse import ArgumentParser
from __future__ import annotations
from ..App import App
from .Cmd import Cmd as CmdBase
from typing import TYPE_CHECKING
class CmdPlatform(CmdBase): # export
from .Cmd import Cmd, Parent
def __init__(self, parent: App) -> None:
if TYPE_CHECKING:
from argparse import ArgumentParser
class CmdPlatform(Cmd): # export
def __init__(self, parent: Parent) -> None:
super().__init__(
parent, 'platform', help = 'Miscellaneous platform-related comamnds'
)

View file

@ -1,11 +1,15 @@
from argparse import ArgumentParser
from __future__ import annotations
from ..App import App
from .Cmd import Cmd as CmdBase
from typing import TYPE_CHECKING
class CmdPosix(CmdBase): # export
from .Cmd import Cmd, Parent
def __init__(self, parent: App) -> None:
if TYPE_CHECKING:
from argparse import ArgumentParser
class CmdPosix(Cmd): # export
def __init__(self, parent: Parent) -> None:
super().__init__(
parent,
'posix',

View file

@ -1,13 +1,17 @@
from __future__ import annotations
import sys
from argparse import ArgumentParser
from typing import TYPE_CHECKING
from ..App import App
from .Cmd import Cmd as CmdBase
from .Cmd import Cmd, Parent
class CmdProjects(CmdBase): # export
if TYPE_CHECKING:
from argparse import ArgumentParser
def __init__(self, parent: App) -> None:
class CmdProjects(Cmd): # export
def __init__(self, parent: Parent) -> None:
super().__init__(
parent,
'projects',

View file

@ -1,11 +1,15 @@
from argparse import ArgumentParser
from __future__ import annotations
from ..App import App
from .Cmd import Cmd as CmdBase
from typing import TYPE_CHECKING
class CmdSecrets(CmdBase): # export
from .Cmd import Cmd, Parent
def __init__(self, parent: App) -> None:
if TYPE_CHECKING:
from argparse import ArgumentParser
class CmdSecrets(Cmd): # export
def __init__(self, parent: Parent) -> None:
super().__init__(parent, 'secrets', help = 'Manage package secrets')
self.load_subcommands()

View file

@ -2,12 +2,19 @@ from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from ..CmdPkg import CmdPkg
from ...CmdBase import CmdBase as Base
from ..CmdPkg import CmdPkg as Parent
from ..Cmd import Cmd as Base
if TYPE_CHECKING:
from ...lib.Distro import Distro
class Cmd(Base): # export
def __init__(self, parent: CmdPkg, name: str, help: str) -> None:
def __init__(self, parent: Parent, name: str, help: str) -> None:
super().__init__(parent, name, help)
@property
def distro(self) -> Distro:
return self.app.distro
__all__ = ['Parent', 'Cmd']

View file

@ -1,11 +1,15 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from ..CmdPkg import CmdPkg
from .Cmd import Cmd
from typing import TYPE_CHECKING
from .Cmd import Cmd, Parent
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdDelete(Cmd): # export
def __init__(self, parent: CmdPkg) -> None:
def __init__(self, parent: Parent) -> None:
super().__init__(parent, 'delete', help = 'Delete packages by name')
def add_arguments(self, parser: ArgumentParser) -> None:

View file

@ -1,11 +1,15 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from ..CmdPkg import CmdPkg
from .Cmd import Cmd
from typing import TYPE_CHECKING
from .Cmd import Cmd, Parent
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdDup(Cmd): # export
def __init__(self, parent: CmdPkg) -> None:
def __init__(self, parent: Parent) -> None:
super().__init__(parent, 'dup', help = 'Upgrade distribution')
def add_arguments(self, parser: ArgumentParser) -> None:

View file

@ -1,11 +1,15 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from ..CmdPkg import CmdPkg
from .Cmd import Cmd
from typing import TYPE_CHECKING
from .Cmd import Cmd, Parent
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdInstall(Cmd): # export
def __init__(self, parent: CmdPkg) -> None:
def __init__(self, parent: Parent) -> None:
super().__init__(
parent,
'install',

View file

@ -1,11 +1,15 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from ..CmdPkg import CmdPkg
from .NamedPkgsCmd import NamedPkgsCmd as Base
from typing import TYPE_CHECKING
class CmdLs(Base): # export
from .Cmd import Cmd, Parent
def __init__(self, parent: CmdPkg) -> None:
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdLs(Cmd): # export
def __init__(self, parent: Parent) -> None:
super().__init__(parent, 'ls', help = 'List package contents')
def add_arguments(self, parser: ArgumentParser) -> None:

View file

@ -1,11 +1,15 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from ..CmdPkg import CmdPkg
from .NamedPkgsCmd import NamedPkgsCmd as Base
from typing import TYPE_CHECKING
class CmdMeta(Base): # export
from .NamedPkgsCmd import NamedPkgsCmd, Parent
def __init__(self, parent: CmdPkg) -> None:
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdMeta(NamedPkgsCmd): # export
def __init__(self, parent: Parent) -> None:
super().__init__(parent, 'meta', help = 'List package metadata')
def add_arguments(self, parser: ArgumentParser) -> None:

View file

@ -1,11 +1,15 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from ..CmdPkg import CmdPkg
from .Cmd import Cmd
from typing import TYPE_CHECKING
from .Cmd import Cmd, Parent
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdRebootRequired(Cmd): # export
def __init__(self, parent: CmdPkg) -> None:
def __init__(self, parent: Parent) -> None:
super().__init__(
parent,
'reboot-required',

View file

@ -1,11 +1,15 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from ..CmdPkg import CmdPkg
from .Cmd import Cmd
from typing import TYPE_CHECKING
from .Cmd import Cmd, Parent
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdRefresh(Cmd): # export
def __init__(self, parent: CmdPkg) -> None:
def __init__(self, parent: Parent) -> None:
super().__init__(
parent,
'refresh',

View file

@ -1,12 +1,16 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from typing import TYPE_CHECKING
from ...lib.PackageFilter import PackageFilterString
from ..CmdPkg import CmdPkg
from .Cmd import Cmd
from .Cmd import Cmd, Parent
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdSelect(Cmd): # export
def __init__(self, parent: CmdPkg) -> None:
def __init__(self, parent: Parent) -> None:
super().__init__(parent, 'select', help = 'Select packages by filter')
def add_arguments(self, parser: ArgumentParser) -> None:

View file

@ -1,9 +1,13 @@
from argparse import ArgumentParser
from __future__ import annotations
from ..CmdPkg import CmdPkg as Parent
from .Cmd import Cmd as Base
from typing import TYPE_CHECKING
class NamedPkgsCmd(Base): # export
from .Cmd import Cmd, Parent
if TYPE_CHECKING:
from argparse import ArgumentParser
class NamedPkgsCmd(Cmd): # export
def __init__(self, parent: Parent, name: str, help: str) -> None:
super().__init__(parent, name, help)
@ -11,3 +15,5 @@ class NamedPkgsCmd(Base): # export
def add_arguments(self, parser: ArgumentParser) -> None:
super().add_arguments(parser)
parser.add_argument('names', nargs = '*', help = 'Package names')
__all__ = ['NamedPkgsCmd', 'Parent']

View file

@ -1,13 +1,11 @@
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from ..CmdPlatform import CmdPlatform
from ..Cmd import Cmd as Base
from ...CmdBase import CmdBase as Base
from ..CmdPlatform import CmdPlatform as Parent
class Cmd(Base): # export
def __init__(self, parent: CmdPlatform, name: str, help: str) -> None:
def __init__(self, parent: Parent, name: str, help: str) -> None:
super().__init__(parent, name, help)
__all__ = ['Parent', 'Cmd']

View file

@ -1,12 +1,16 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from typing import TYPE_CHECKING
from ...lib.Distro import Distro
from ..Cmd import Cmd
from ..CmdPlatform import CmdPlatform
from .Cmd import Cmd, Parent
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdInfo(Cmd): # export
def __init__(self, parent: CmdPlatform) -> None:
def __init__(self, parent: Parent) -> None:
super().__init__(
parent, 'info', help = 'Retrieve information about target platform'
)

View file

@ -1,17 +1,19 @@
from __future__ import annotations
from argparse import ArgumentParser
from typing import TYPE_CHECKING
from ...CmdBase import CmdBase
from ...CmdBase import CmdBase as Base
from ..CmdPosix import CmdPosix as Parent
if TYPE_CHECKING:
from ..CmdPosix import CmdPosix as Parent
from argparse import ArgumentParser
class Cmd(CmdBase): # export
class Cmd(Base): # export
def __init__(self, parent: Parent, name: str, help: str) -> None:
super().__init__(parent, name, help)
def add_arguments(self, parser: ArgumentParser) -> None:
super().add_arguments(parser)
__all__ = ['Parent', 'Cmd']

View file

@ -3,16 +3,14 @@ from __future__ import annotations
from typing import TYPE_CHECKING
from ...lib.util import copy
from .Cmd import Cmd
from .Cmd import Cmd, Parent
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
from ..CmdPosix import CmdPosix
class CmdCopy(Cmd): # export
def __init__(self, parent: CmdPosix) -> None:
def __init__(self, parent: Parent) -> None:
super().__init__(parent, 'copy', help = 'Copy files')
def add_arguments(self, parser: ArgumentParser) -> None:

View file

@ -1,9 +1,13 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from ..CmdPosix import CmdPosix as Parent
from .Cmd import Cmd as Base
from typing import TYPE_CHECKING
class CmdTar(Base): # export
from .Cmd import Cmd, Parent
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdTar(Cmd): # export
def __init__(self, parent: Parent) -> None:
super().__init__(parent, 'tar', help = 'Handle tar archives')

View file

@ -1,14 +1,19 @@
from argparse import ArgumentParser
from collections.abc import AsyncIterator
from contextlib import asynccontextmanager
from __future__ import annotations
from ....CmdBase import CmdBase
from contextlib import asynccontextmanager
from typing import TYPE_CHECKING
from ....CmdBase import CmdBase as Base
from ....lib.FileContext import FileContext
from ....lib.ProcFilterGpg import ProcFilterGpg
from ....lib.TarIo import TarIo
from ..CmdTar import CmdTar as Parent
class Cmd(CmdBase): # export
if TYPE_CHECKING:
from argparse import ArgumentParser
from collections.abc import AsyncIterator
class Cmd(Base): # export
def __init__(self, parent: Parent, name: str, help: str) -> None:
super().__init__(parent, name, help)
@ -27,3 +32,5 @@ class Cmd(CmdBase): # export
parser.add_argument(
'-f', '--archive-path', required = True, help = 'Archive path'
)
__all__ = ['Parent', 'Cmd']

View file

@ -1,9 +1,11 @@
from __future__ import annotations
from argparse import ArgumentParser, Namespace
from ....lib.log import DEBUG, log
from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdExtract(Cmd): # export

View file

@ -1,9 +1,14 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from typing import TYPE_CHECKING
from .Cmd import Cmd, Parent
from .lib.pkg_relations import VersionSyntax
from .lib.pkg_relations import pkg_relations as pkg_relations_list
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class BaseCmdPkgRelations(Cmd):
def pkg_relations(self, rel_type: str, args: Namespace) -> str:
@ -130,3 +135,5 @@ class BaseCmdPkgRelations(Cmd):
async def _run(self, args: Namespace) -> None:
return self.print_pkg_relations(self.relation, args)
__all__ = ['Parent', 'BaseCmdPkgRelations']

View file

@ -1,14 +1,19 @@
from __future__ import annotations
from argparse import ArgumentParser
from typing import TYPE_CHECKING
from ...CmdBase import CmdBase
from ...CmdBase import CmdBase as Base
from ..CmdProjects import CmdProjects as Parent
class Cmd(CmdBase): # export
if TYPE_CHECKING:
from argparse import ArgumentParser
class Cmd(Base): # export
def __init__(self, parent: Parent, name: str, help: str) -> None:
super().__init__(parent, name, help)
def add_arguments(self, parser: ArgumentParser) -> None:
super().add_arguments(parser)
__all__ = ['Parent', 'Cmd']

View file

@ -1,14 +1,18 @@
from __future__ import annotations
import datetime
import os
import re
from argparse import ArgumentParser, Namespace
from functools import lru_cache
from ...App import Scope
from ...lib.log import DEBUG, ERR, NOTICE, log
from ...lib.util import get_profile_env, pretty_cmd
from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdBuild(Cmd): # export

View file

@ -1,14 +1,14 @@
from __future__ import annotations
from argparse import ArgumentParser, Namespace
from typing import TYPE_CHECKING
from ...lib.base import InputMode
from ...lib.log import NOTICE, log
from .Cmd import Cmd, Parent
from ...lib.base import Result
if TYPE_CHECKING:
from ...lib.base import Result
from argparse import ArgumentParser, Namespace
class CmdCanonicalizeRemotes(Cmd): # export

View file

@ -1,7 +1,11 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from ...App import Scope
from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdCflags(Cmd): # export

View file

@ -1,8 +1,11 @@
from __future__ import annotations
import sys
from argparse import ArgumentParser
from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser
class CmdCheck(Cmd): # export

View file

@ -1,6 +1,10 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdCommands(Cmd): # export

View file

@ -1,7 +1,11 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from .Cmd import Cmd, Parent
from .lib.templates import tmpl_render
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdCreatePkgConfig(Cmd): # export

View file

@ -1,7 +1,11 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from ...App import Scope
from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdExepath(Cmd): # export

View file

@ -1,11 +1,14 @@
from __future__ import annotations
import os
import re
from argparse import ArgumentParser, Namespace
from ...lib.log import DEBUG, log
from ...lib.Uri import Uri
from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdGetAuthInfo(Cmd): # export

View file

@ -1,6 +1,10 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdGetval(Cmd): # export

View file

@ -1,6 +1,10 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdHtdocsDir(Cmd): # export

View file

@ -1,7 +1,11 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from ...App import Scope
from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdLdflags(Cmd): # export

View file

@ -1,7 +1,11 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from ...App import Scope
from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdLdlibpath(Cmd): # export

View file

@ -1,6 +1,10 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdLibname(Cmd): # export

View file

@ -1,12 +1,15 @@
from __future__ import annotations
import os
import re
from argparse import ArgumentParser, Namespace
from ...lib.log import DEBUG, log
from ...lib.Uri import Uri
from ...lib.util import get_password, get_username, run_curl_into
from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdListRepos(Cmd): # export

View file

@ -1,9 +1,12 @@
from __future__ import annotations
import re
from argparse import ArgumentParser, Namespace
from ...lib.log import DEBUG, log
from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdModules(Cmd): # export

View file

@ -1,7 +1,11 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from ...App import Scope
from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdPath(Cmd): # export

View file

@ -1,5 +1,4 @@
from .BaseCmdPkgRelations import BaseCmdPkgRelations as Base
from .Cmd import Parent
from .BaseCmdPkgRelations import BaseCmdPkgRelations as Base, Parent
class CmdPkgConflicts(Base): # export

View file

@ -1,5 +1,4 @@
from .BaseCmdPkgRelations import BaseCmdPkgRelations as Base
from .Cmd import Parent
from .BaseCmdPkgRelations import BaseCmdPkgRelations as Base, Parent
class CmdPkgProvides(Base): # export

View file

@ -1,5 +1,4 @@
from .BaseCmdPkgRelations import BaseCmdPkgRelations as Base
from .Cmd import Parent
from .BaseCmdPkgRelations import BaseCmdPkgRelations as Base, Parent
class CmdPkgRequires(Base): # export

View file

@ -1,7 +1,11 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from ...lib.log import WARNING, log
from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdProjDir(Cmd): # export

View file

@ -1,7 +1,11 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from ...App import Scope
from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdPythonpath(Cmd): # export

View file

@ -1,9 +1,12 @@
from __future__ import annotations
import os
from argparse import ArgumentParser, Namespace
from ...App import Scope
from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdPythonpathOrig(Cmd): # export

View file

@ -1,8 +1,12 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from ...App import Scope
from ...lib.log import DEBUG, log
from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
# TODO: seems at least partly redundant to CmdPkgRequires / print_pkg_relations
class CmdRequiredOsPkg(Cmd): # export

View file

@ -1,6 +1,10 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdSummary(Cmd): # export

View file

@ -1,6 +1,10 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdTest(Cmd): # export

View file

@ -1,6 +1,10 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdTmplDir(Cmd): # export

View file

@ -1,14 +1,19 @@
from __future__ import annotations
from argparse import ArgumentParser
from typing import TYPE_CHECKING
from ....CmdBase import CmdBase
from ....CmdBase import CmdBase as Base
from ..CmdCheck import CmdCheck as Parent
class Cmd(CmdBase): # export
if TYPE_CHECKING:
from argparse import ArgumentParser
class Cmd(Base): # export
def __init__(self, parent: Parent, name: str, help: str) -> None:
super().__init__(parent, name, help)
def add_arguments(self, parser: ArgumentParser) -> None:
super().add_arguments(parser)
__all__ = ['Parent', 'Cmd']

View file

@ -1,7 +1,11 @@
from argparse import ArgumentParser, Namespace
from __future__ import annotations
from ....lib.log import NOTICE, log
from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdDep(Cmd): # export

View file

@ -1,19 +1,19 @@
from __future__ import annotations
from argparse import ArgumentParser
from functools import cached_property
from typing import TYPE_CHECKING
from ...CmdBase import CmdBase
from ...CmdBase import CmdBase as Base
from ..CmdSecrets import CmdSecrets as Parent
if TYPE_CHECKING:
from typing import Iterable
from .lib.base import Attrs
from .lib.DistroContext import DistroContext
class Cmd(CmdBase): # export
if TYPE_CHECKING:
from argparse import ArgumentParser
from typing import Iterable
from .lib.base import Attrs
class Cmd(Base): # export
@cached_property
def ctx(self) -> DistroContext:
@ -49,3 +49,5 @@ class Cmd(CmdBase): # export
def add_arguments(self, parser: ArgumentParser) -> None:
super().add_arguments(parser)
parser.add_argument('packages', nargs = '*', help = 'Package names')
__all__ = ['Parent', 'Cmd']

View file

@ -2,17 +2,15 @@ from __future__ import annotations
from typing import TYPE_CHECKING
from .Cmd import Cmd
from .Cmd import Cmd, Parent
from .lib.base import Attrs
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
from ..CmdSecrets import CmdSecrets
class CmdCompileTemplates(Cmd): # export
def __init__(self, parent: CmdSecrets) -> None:
def __init__(self, parent: Parent) -> None:
super().__init__(
parent, 'compile-templates', help = 'Compile package template files'
)

View file

@ -2,16 +2,14 @@ from __future__ import annotations
from typing import TYPE_CHECKING
from .Cmd import Cmd
from .Cmd import Cmd, Parent
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
from ..CmdSecrets import CmdSecrets
class CmdInstall(Cmd): # export
def __init__(self, parent: CmdSecrets) -> None:
def __init__(self, parent: Parent) -> None:
super().__init__(
parent,
'install',

View file

@ -2,16 +2,14 @@ from __future__ import annotations
from typing import TYPE_CHECKING
from .Cmd import Cmd
from .Cmd import Cmd, Parent
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
from ..CmdSecrets import CmdSecrets
class CmdListCompilationOutput(Cmd): # export
def __init__(self, parent: CmdSecrets) -> None:
def __init__(self, parent: Parent) -> None:
super().__init__(
parent,
'list-compilation-output',

View file

@ -2,16 +2,14 @@ from __future__ import annotations
from typing import TYPE_CHECKING
from .Cmd import Cmd
from .Cmd import Cmd, Parent
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
from ..CmdSecrets import CmdSecrets
class CmdListSecrets(Cmd): # export
def __init__(self, parent: CmdSecrets) -> None:
def __init__(self, parent: Parent) -> None:
super().__init__(parent, 'list-secrets', help = 'List package secret files')
def add_arguments(self, parser: ArgumentParser) -> None:

View file

@ -2,16 +2,14 @@ from __future__ import annotations
from typing import TYPE_CHECKING
from .Cmd import Cmd
from .Cmd import Cmd, Parent
if TYPE_CHECKING:
from argparse import Namespace
from ..CmdSecrets import CmdSecrets
class CmdListTemplates(Cmd): # export
def __init__(self, parent: CmdSecrets) -> None:
def __init__(self, parent: Parent) -> None:
super().__init__(parent, 'list-templates', help = 'List package template files')
async def _run(self, args: Namespace) -> None:

View file

@ -8,10 +8,10 @@ from typing import TYPE_CHECKING
from ....lib.log import DEBUG, NOTICE, WARNING, log
from ....lib.ProcFilterGpg import ProcFilterGpg
from .base import Attrs
from .FilesContext import FilesContext
if TYPE_CHECKING:
from .base import Attrs
from typing import Iterable
from ....lib.Distro import Distro

View file

@ -7,11 +7,11 @@ from tarfile import TarFile
from typing import TYPE_CHECKING, Callable
from ....lib.log import DEBUG, log
from ....lib.ExecContext import ExecContext
if TYPE_CHECKING:
from typing import Iterable
from ....lib.ExecContext import ExecContext
from ....lib.FileContext import FileContext
def filter(

View file

@ -3,10 +3,10 @@ from __future__ import annotations
from typing import TYPE_CHECKING
from ....lib.ec.Local import Local
from ....lib.FileContext import FileContext
from .FilesContext import FilesContext
if TYPE_CHECKING:
from ....lib.FileContext import FileContext
from .base import Attrs
async def compile_template_file(

View file

@ -4,8 +4,10 @@ import asyncio
import concurrent.futures
import contextlib
from collections.abc import Awaitable, Generator
from typing import TypeVar
from typing import TypeVar, TYPE_CHECKING
if TYPE_CHECKING:
from collections.abc import Awaitable, Generator
T = TypeVar('T')

View file

@ -3,13 +3,13 @@ from __future__ import annotations
import abc
import sys
from argparse import ArgumentParser
from typing import TYPE_CHECKING
from .log import ERR
from .Types import LoadTypes, Types
if TYPE_CHECKING:
from argparse import ArgumentParser
from typing import Any
from .App import App

View file

@ -9,11 +9,12 @@ from functools import cached_property
from typing import TYPE_CHECKING
from .log import ERR, INFO, WARNING, log
from .base import InputMode
if TYPE_CHECKING:
from typing import Iterable
from .base import InputMode, Result
from .base import Result
from .ExecContext import ExecContext
from .Package import Package
from .PackageFilter import PackageFilter

View file

@ -8,10 +8,11 @@ from typing import TYPE_CHECKING
from .log import DEBUG, ERR, log
from .Uri import Uri
from .ProcFilter import ProcPipeline
if TYPE_CHECKING:
from .base import Result, StatResult
from .ProcFilter import ProcFilter, ProcPipeline
from .ProcFilter import ProcFilter
class FileContext(abc.ABC):

View file

@ -1,7 +1,11 @@
from __future__ import annotations
import abc
import re
from .Package import Package
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from .Package import Package
class PackageFilter(abc.ABC):

View file

@ -2,10 +2,10 @@ from __future__ import annotations
from typing import TYPE_CHECKING
from .base import Result
from .ProcFilter import ProcFilter
if TYPE_CHECKING:
from .base import Result
from .ExecContext import ExecContext
class ProcFilterGpg(ProcFilter):

View file

@ -6,10 +6,13 @@ import tarfile
from tarfile import TarFile, TarInfo
from .base import StatResult
from .CopyContext import CopyContext
from .ExecContext import ExecContext
from .log import DEBUG, ERR, log
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from .base import StatResult
class TarIo(CopyContext):

View file

@ -1,14 +1,15 @@
from __future__ import annotations
import abc
import os
import re
import sys
from collections.abc import Iterator
from typing import TYPE_CHECKING, Generic, Iterable, TypeVar
from .log import OFF, log, parse_log_level
if TYPE_CHECKING:
from collections.abc import Iterator
from typing import Any
T = TypeVar('T')

View file

@ -1,9 +1,10 @@
from __future__ import annotations
import os
from enum import Enum, auto
from typing import NamedTuple, TypeAlias
from typing import NamedTuple, TypeAlias, TYPE_CHECKING
if TYPE_CHECKING:
import os
class InputMode(Enum):
Interactive = auto()

View file

@ -2,10 +2,10 @@ from __future__ import annotations
from typing import TYPE_CHECKING
from ..base import Result
from ..FileContext import FileContext as Base
if TYPE_CHECKING:
from ..base import Result
from ..ExecContext import ExecContext
from ..Uri import Uri
from .Local import Local

View file

@ -8,13 +8,12 @@ import sys
from enum import Flag, auto
from typing import TYPE_CHECKING
from ..base import Result
from ..ExecContext import ExecContext
from ..log import DEBUG, ERR, INFO, NOTICE, WARNING, log
from ..Uri import Uri
if TYPE_CHECKING:
from ..Uri import Uri
from ..base import Result
class SSHClient(ExecContext):

View file

@ -3,6 +3,8 @@ from __future__ import annotations
from typing import TYPE_CHECKING
import paramiko # type: ignore[import-untyped] # error: Library stubs not installed for "paramiko"
import paramiko.agent # type: ignore[import-untyped]
import paramiko.SCPClient # type: ignore[import-untyped]
from ...base import Result
from ...log import ERR, log
@ -12,9 +14,6 @@ from .util import join_cmd
if TYPE_CHECKING:
from typing import Any
import paramiko.agent # type: ignore[import-untyped]
import paramiko.SCPClient # type: ignore[import-untyped]
class Paramiko(Base):
def __init__(self, uri, *args, **kwargs) -> None:

View file

@ -4,7 +4,6 @@ import json
import os
import sys
from argparse import Namespace
from enum import Enum, auto
from typing import TYPE_CHECKING, Iterable, TypeVar, cast
@ -13,6 +12,7 @@ from .log import DEBUG, ERR, log
from .Uri import Uri
if TYPE_CHECKING:
from argparse import Namespace
from .ExecContext import ExecContext
from .FileContext import FileContext
from .ProcFilter import ProcFilter, ProcPipeline
@ -93,7 +93,7 @@ async def run_curl_into(
raise TypeError(
f'Expected {expected_type.__name__}, got {type(ret).__name__} from Curl'
)
return cast(T, ret)
return cast('T', ret)
async def run_askpass(
askpass_env: list[str],