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:
parent
7a65a7b5e1
commit
5d1ba6e15a
77 changed files with 382 additions and 196 deletions
|
|
@ -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']
|
||||
|
|
|
|||
|
|
@ -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']
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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']
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue