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

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