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