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] [tool.ruff.lint]
future-annotations = true
select = [ select = [
"F", # Pyflakes, includes F401 "F", # Pyflakes, includes F401
"E", # pycodestyle errors "E", # pycodestyle errors
"W", # pycodestyle warnings "W", # pycodestyle warnings
"TC", # type-checking import placement rules
"FA", # future annotations rules
] ]
ignore = [ ignore = [

View file

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

View file

@ -2,15 +2,15 @@ from __future__ import annotations
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from ..CmdBase import CmdBase from ..App import App as Parent
from ..CmdBase import CmdBase as Base
if TYPE_CHECKING: if TYPE_CHECKING:
from ..App import App
from ..lib.Distro import Distro 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) super().__init__(parent, name, help)
async def _run(self, args): async def _run(self, args):
@ -20,3 +20,5 @@ class Cmd(CmdBase): # export
@property @property
def distro(self) -> Distro: def distro(self) -> Distro:
return self.app.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 typing import TYPE_CHECKING
from .Cmd import Cmd as CmdBase
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') super().__init__(parent, 'pkg', help = 'System package manager wrapper')
self.load_subcommands() self.load_subcommands()

View file

@ -1,11 +1,15 @@
from argparse import ArgumentParser from __future__ import annotations
from ..App import App from typing import TYPE_CHECKING
from .Cmd import Cmd as CmdBase
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__( super().__init__(
parent, 'platform', help = 'Miscellaneous platform-related comamnds' 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 typing import TYPE_CHECKING
from .Cmd import Cmd as CmdBase
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__( super().__init__(
parent, parent,
'posix', 'posix',

View file

@ -1,13 +1,17 @@
from __future__ import annotations
import sys import sys
from argparse import ArgumentParser from typing import TYPE_CHECKING
from ..App import App from .Cmd import Cmd, Parent
from .Cmd import Cmd as CmdBase
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__( super().__init__(
parent, parent,
'projects', 'projects',

View file

@ -1,11 +1,15 @@
from argparse import ArgumentParser from __future__ import annotations
from ..App import App from typing import TYPE_CHECKING
from .Cmd import Cmd as CmdBase
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') super().__init__(parent, 'secrets', help = 'Manage package secrets')
self.load_subcommands() self.load_subcommands()

View file

@ -2,12 +2,19 @@ from __future__ import annotations
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
if TYPE_CHECKING: from ...CmdBase import CmdBase as Base
from ..CmdPkg import CmdPkg from ..CmdPkg import CmdPkg as Parent
from ..Cmd import Cmd as Base if TYPE_CHECKING:
from ...lib.Distro import Distro
class Cmd(Base): # export 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) 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 typing import TYPE_CHECKING
from .Cmd import Cmd
from .Cmd import Cmd, Parent
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdDelete(Cmd): # export 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') super().__init__(parent, 'delete', help = 'Delete packages by name')
def add_arguments(self, parser: ArgumentParser) -> None: 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 typing import TYPE_CHECKING
from .Cmd import Cmd
from .Cmd import Cmd, Parent
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdDup(Cmd): # export class CmdDup(Cmd): # export
def __init__(self, parent: CmdPkg) -> None: def __init__(self, parent: Parent) -> None:
super().__init__(parent, 'dup', help = 'Upgrade distribution') super().__init__(parent, 'dup', help = 'Upgrade distribution')
def add_arguments(self, parser: ArgumentParser) -> None: 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 typing import TYPE_CHECKING
from .Cmd import Cmd
from .Cmd import Cmd, Parent
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdInstall(Cmd): # export class CmdInstall(Cmd): # export
def __init__(self, parent: CmdPkg) -> None: def __init__(self, parent: Parent) -> None:
super().__init__( super().__init__(
parent, parent,
'install', 'install',

View file

@ -1,11 +1,15 @@
from argparse import ArgumentParser, Namespace from __future__ import annotations
from ..CmdPkg import CmdPkg from typing import TYPE_CHECKING
from .NamedPkgsCmd import NamedPkgsCmd as Base
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') super().__init__(parent, 'ls', help = 'List package contents')
def add_arguments(self, parser: ArgumentParser) -> None: 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 typing import TYPE_CHECKING
from .NamedPkgsCmd import NamedPkgsCmd as Base
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') super().__init__(parent, 'meta', help = 'List package metadata')
def add_arguments(self, parser: ArgumentParser) -> None: 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 typing import TYPE_CHECKING
from .Cmd import Cmd
from .Cmd import Cmd, Parent
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdRebootRequired(Cmd): # export class CmdRebootRequired(Cmd): # export
def __init__(self, parent: CmdPkg) -> None: def __init__(self, parent: Parent) -> None:
super().__init__( super().__init__(
parent, parent,
'reboot-required', 'reboot-required',

View file

@ -1,11 +1,15 @@
from argparse import ArgumentParser, Namespace from __future__ import annotations
from ..CmdPkg import CmdPkg from typing import TYPE_CHECKING
from .Cmd import Cmd
from .Cmd import Cmd, Parent
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdRefresh(Cmd): # export class CmdRefresh(Cmd): # export
def __init__(self, parent: CmdPkg) -> None: def __init__(self, parent: Parent) -> None:
super().__init__( super().__init__(
parent, parent,
'refresh', '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 ...lib.PackageFilter import PackageFilterString
from ..CmdPkg import CmdPkg from .Cmd import Cmd, Parent
from .Cmd import Cmd
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdSelect(Cmd): # export 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') super().__init__(parent, 'select', help = 'Select packages by filter')
def add_arguments(self, parser: ArgumentParser) -> None: 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 typing import TYPE_CHECKING
from .Cmd import Cmd as Base
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: def __init__(self, parent: Parent, name: str, help: str) -> None:
super().__init__(parent, name, help) super().__init__(parent, name, help)
@ -11,3 +15,5 @@ class NamedPkgsCmd(Base): # export
def add_arguments(self, parser: ArgumentParser) -> None: def add_arguments(self, parser: ArgumentParser) -> None:
super().add_arguments(parser) super().add_arguments(parser)
parser.add_argument('names', nargs = '*', help = 'Package names') parser.add_argument('names', nargs = '*', help = 'Package names')
__all__ = ['NamedPkgsCmd', 'Parent']

View file

@ -1,13 +1,11 @@
from __future__ import annotations from __future__ import annotations
from typing import TYPE_CHECKING from ...CmdBase import CmdBase as Base
from ..CmdPlatform import CmdPlatform as Parent
if TYPE_CHECKING:
from ..CmdPlatform import CmdPlatform
from ..Cmd import Cmd as Base
class Cmd(Base): # export 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) 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 ...lib.Distro import Distro
from ..Cmd import Cmd from .Cmd import Cmd, Parent
from ..CmdPlatform import CmdPlatform
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdInfo(Cmd): # export class CmdInfo(Cmd): # export
def __init__(self, parent: CmdPlatform) -> None: def __init__(self, parent: Parent) -> None:
super().__init__( super().__init__(
parent, 'info', help = 'Retrieve information about target platform' parent, 'info', help = 'Retrieve information about target platform'
) )

View file

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

View file

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

View file

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

View file

@ -1,9 +1,11 @@
from __future__ import annotations from __future__ import annotations
from argparse import ArgumentParser, Namespace
from ....lib.log import DEBUG, log from ....lib.log import DEBUG, log
from .Cmd import Cmd, Parent from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdExtract(Cmd): # export 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 .Cmd import Cmd, Parent
from .lib.pkg_relations import VersionSyntax from .lib.pkg_relations import VersionSyntax
from .lib.pkg_relations import pkg_relations as pkg_relations_list from .lib.pkg_relations import pkg_relations as pkg_relations_list
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class BaseCmdPkgRelations(Cmd): class BaseCmdPkgRelations(Cmd):
def pkg_relations(self, rel_type: str, args: Namespace) -> str: def pkg_relations(self, rel_type: str, args: Namespace) -> str:
@ -130,3 +135,5 @@ class BaseCmdPkgRelations(Cmd):
async def _run(self, args: Namespace) -> None: async def _run(self, args: Namespace) -> None:
return self.print_pkg_relations(self.relation, args) return self.print_pkg_relations(self.relation, args)
__all__ = ['Parent', 'BaseCmdPkgRelations']

View file

@ -1,14 +1,19 @@
from __future__ import annotations 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 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: def __init__(self, parent: Parent, name: str, help: str) -> None:
super().__init__(parent, name, help) super().__init__(parent, name, help)
def add_arguments(self, parser: ArgumentParser) -> None: def add_arguments(self, parser: ArgumentParser) -> None:
super().add_arguments(parser) super().add_arguments(parser)
__all__ = ['Parent', 'Cmd']

View file

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

View file

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

View file

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

View file

@ -1,8 +1,11 @@
from __future__ import annotations
import sys import sys
from argparse import ArgumentParser
from .Cmd import Cmd, Parent from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser
class CmdCheck(Cmd): # export 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 .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdCommands(Cmd): # export 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 .Cmd import Cmd, Parent
from .lib.templates import tmpl_render from .lib.templates import tmpl_render
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdCreatePkgConfig(Cmd): # export class CmdCreatePkgConfig(Cmd): # export

View file

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

View file

@ -1,11 +1,14 @@
from __future__ import annotations
import os import os
import re import re
from argparse import ArgumentParser, Namespace
from ...lib.log import DEBUG, log from ...lib.log import DEBUG, log
from ...lib.Uri import Uri from ...lib.Uri import Uri
from .Cmd import Cmd, Parent from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdGetAuthInfo(Cmd): # export 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 .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdGetval(Cmd): # export 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 .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdHtdocsDir(Cmd): # export class CmdHtdocsDir(Cmd): # export

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,5 +1,4 @@
from .BaseCmdPkgRelations import BaseCmdPkgRelations as Base from .BaseCmdPkgRelations import BaseCmdPkgRelations as Base, Parent
from .Cmd import Parent
class CmdPkgRequires(Base): # export 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 ...lib.log import WARNING, log
from .Cmd import Cmd, Parent from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdProjDir(Cmd): # export class CmdProjDir(Cmd): # export

View file

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

View file

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

View file

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

View file

@ -1,14 +1,19 @@
from __future__ import annotations 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 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: def __init__(self, parent: Parent, name: str, help: str) -> None:
super().__init__(parent, name, help) super().__init__(parent, name, help)
def add_arguments(self, parser: ArgumentParser) -> None: def add_arguments(self, parser: ArgumentParser) -> None:
super().add_arguments(parser) 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 ....lib.log import NOTICE, log
from .Cmd import Cmd, Parent from .Cmd import Cmd, Parent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdDep(Cmd): # export class CmdDep(Cmd): # export

View file

@ -1,19 +1,19 @@
from __future__ import annotations from __future__ import annotations
from argparse import ArgumentParser
from functools import cached_property from functools import cached_property
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from ...CmdBase import CmdBase from ...CmdBase import CmdBase as Base
from ..CmdSecrets import CmdSecrets as Parent from ..CmdSecrets import CmdSecrets as Parent
if TYPE_CHECKING:
from typing import Iterable
from .lib.base import Attrs
from .lib.DistroContext import DistroContext 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 @cached_property
def ctx(self) -> DistroContext: def ctx(self) -> DistroContext:
@ -49,3 +49,5 @@ class Cmd(CmdBase): # export
def add_arguments(self, parser: ArgumentParser) -> None: def add_arguments(self, parser: ArgumentParser) -> None:
super().add_arguments(parser) super().add_arguments(parser)
parser.add_argument('packages', nargs = '*', help = 'Package names') 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 typing import TYPE_CHECKING
from .Cmd import Cmd from .Cmd import Cmd, Parent
from .lib.base import Attrs from .lib.base import Attrs
if TYPE_CHECKING: if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace from argparse import ArgumentParser, Namespace
from ..CmdSecrets import CmdSecrets
class CmdCompileTemplates(Cmd): # export class CmdCompileTemplates(Cmd): # export
def __init__(self, parent: CmdSecrets) -> None: def __init__(self, parent: Parent) -> None:
super().__init__( super().__init__(
parent, 'compile-templates', help = 'Compile package template files' parent, 'compile-templates', help = 'Compile package template files'
) )

View file

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

View file

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

View file

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

View file

@ -2,16 +2,14 @@ from __future__ import annotations
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from .Cmd import Cmd from .Cmd import Cmd, Parent
if TYPE_CHECKING: if TYPE_CHECKING:
from argparse import Namespace from argparse import Namespace
from ..CmdSecrets import CmdSecrets
class CmdListTemplates(Cmd): # export 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') super().__init__(parent, 'list-templates', help = 'List package template files')
async def _run(self, args: Namespace) -> None: 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.log import DEBUG, NOTICE, WARNING, log
from ....lib.ProcFilterGpg import ProcFilterGpg from ....lib.ProcFilterGpg import ProcFilterGpg
from .base import Attrs
from .FilesContext import FilesContext from .FilesContext import FilesContext
if TYPE_CHECKING: if TYPE_CHECKING:
from .base import Attrs
from typing import Iterable from typing import Iterable
from ....lib.Distro import Distro from ....lib.Distro import Distro

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,9 +1,10 @@
from __future__ import annotations from __future__ import annotations
import os
from enum import Enum, auto 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): class InputMode(Enum):
Interactive = auto() Interactive = auto()

View file

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

View file

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

View file

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

View file

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