py-check.mk: Run isort with "make format"
If /usr/bin/isort is found, run it during "make format" to get a defined way the imports are sorted. tool.isort in pyproject.toml is updated to match the other fixers. Commit the fallout of this change. Running the other fixers alone doesn't change the formatting, so this should be safe. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
a7dd607667
commit
5d77955ed9
56 changed files with 109 additions and 67 deletions
|
|
@ -6,7 +6,7 @@ import os
|
|||
import sys
|
||||
|
||||
from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, Namespace
|
||||
from typing import Any, cast, override, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Any, cast, override
|
||||
|
||||
from .AsyncRunner import AsyncRunner
|
||||
from .log import (
|
||||
|
|
@ -21,14 +21,14 @@ from .log import (
|
|||
set_log_flags,
|
||||
set_log_level
|
||||
)
|
||||
|
||||
from .Types import LoadTypes
|
||||
from .util import pretty_cmd
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import types
|
||||
|
||||
from collections.abc import Awaitable, Collection
|
||||
from typing import TypeVar
|
||||
|
||||
T = TypeVar('T')
|
||||
|
||||
class App: # export
|
||||
|
|
@ -119,8 +119,8 @@ class App: # export
|
|||
self.parser = parser
|
||||
|
||||
title = 'Available subcommands'
|
||||
if hasattr(parent, 'name'):
|
||||
title += ' of ' + getattr(parent, 'name')
|
||||
if isinstance(parent, AbstractCmd):
|
||||
title += ' of ' + parent.name
|
||||
subparsers = parser.add_subparsers(
|
||||
title = title, metavar = '', dest = 'command'
|
||||
)
|
||||
|
|
@ -139,7 +139,7 @@ class App: # export
|
|||
sc.cmd, sc.parser, sc.cmd.children, all = all
|
||||
)
|
||||
return
|
||||
args, unknown = self.__parser.parse_known_args()
|
||||
args, _ = self.__parser.parse_known_args()
|
||||
cmd_name = getattr(args, 'command', None)
|
||||
if cmd_name in scs:
|
||||
sc = scs[cmd_name]
|
||||
|
|
@ -185,7 +185,7 @@ class App: # export
|
|||
)
|
||||
self._add_arguments(self.__parser)
|
||||
|
||||
args, unknown = self.__parser.parse_known_args()
|
||||
args, _ = self.__parser.parse_known_args()
|
||||
set_log_flags(args.log_flags)
|
||||
set_log_level(args.log_level)
|
||||
|
||||
|
|
@ -222,7 +222,12 @@ class App: # export
|
|||
async def __aenter__(self) -> None:
|
||||
pass
|
||||
|
||||
async def __aexit__(self, exc_type: Any, exc: Any, tb: Any) -> None:
|
||||
async def __aexit__(
|
||||
self,
|
||||
exc_type: type[BaseException] | None,
|
||||
exc: BaseException | None,
|
||||
tb: types.TracebackType | None,
|
||||
) -> None:
|
||||
pass
|
||||
|
||||
async def __run(self, argv: list[str] | None = None) -> None:
|
||||
|
|
@ -230,16 +235,13 @@ class App: # export
|
|||
try:
|
||||
# Import argcomplete only here to not require it to be compatible
|
||||
# with minimal environments
|
||||
from argcomplete.completers import ( # type: ignore[import-not-found, unused-ignore]
|
||||
BaseCompleter
|
||||
)
|
||||
from argcomplete.completers import BaseCompleter # type: ignore[import-not-found, unused-ignore] # isort: skip
|
||||
|
||||
class NoopCompleter(BaseCompleter): # type: ignore[misc, unused-ignore]
|
||||
|
||||
@override
|
||||
def __call__( # pyright: ignore[reportGeneralTypeIssues]
|
||||
self, *args: Any, **kwargs: Any
|
||||
) -> None:
|
||||
self, *args: Any, **kwargs: Any) -> None:
|
||||
return None
|
||||
|
||||
import argcomplete # type: ignore[import-not-found, unused-ignore]
|
||||
|
|
@ -266,7 +268,7 @@ class App: # export
|
|||
if isinstance(ret, int) and ret >= 0 and ret <= 0xFF:
|
||||
exit_status = ret
|
||||
except Exception as e:
|
||||
log_m(ERR, 'Failed: {}'.format(repr(e) if self.__back_trace else str(e)))
|
||||
log_m(ERR, f'Failed: {repr(e) if self.__back_trace else str(e)}')
|
||||
exit_status = 1
|
||||
# AssertionErrors are programming errors, hence a programmer should
|
||||
# get a chance to figure it out
|
||||
|
|
@ -339,6 +341,7 @@ class App: # export
|
|||
self.__async_runner = None
|
||||
return ret
|
||||
|
||||
|
||||
def run_sub_commands( # export
|
||||
description: str = '',
|
||||
name_filter: str = '^Cmd.*',
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import asyncio
|
|||
import concurrent.futures
|
||||
import contextlib
|
||||
|
||||
from typing import Any, TypeVar, TYPE_CHECKING, cast
|
||||
from typing import TYPE_CHECKING, Any, TypeVar, cast
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Awaitable, Generator
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ import sys
|
|||
from functools import cached_property
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from .log import ERR, INFO, WARNING, log
|
||||
from .base import InputMode
|
||||
from .log import ERR, INFO, WARNING, log
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Collection
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import errno
|
|||
import sys
|
||||
|
||||
from decimal import ROUND_FLOOR, Decimal
|
||||
from typing import Any, override, TYPE_CHECKING, NamedTuple
|
||||
from typing import TYPE_CHECKING, Any, NamedTuple, override
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Type
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ import abc
|
|||
|
||||
from enum import Enum, auto
|
||||
from functools import cached_property
|
||||
from typing import Any, override, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Any, override
|
||||
|
||||
from .log import DEBUG, ERR, log
|
||||
from .Uri import Uri
|
||||
from .ProcFilter import ProcPipeline
|
||||
from .Uri import Uri
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .base import Result, StatResult
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import override, Any
|
||||
from typing import Any, override
|
||||
|
||||
meta_tags = [
|
||||
'name',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import abc
|
||||
import re
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ import io
|
|||
import tarfile
|
||||
|
||||
from tarfile import TarFile, TarInfo
|
||||
from typing import TYPE_CHECKING, Any, override
|
||||
|
||||
from .CopyContext import CopyContext
|
||||
from .ExecContext import ExecContext
|
||||
from .log import DEBUG, ERR, log
|
||||
from typing import TYPE_CHECKING, Any, override
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .base import StatResult
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import os
|
|||
import re
|
||||
import sys
|
||||
|
||||
from typing import Any, override, TYPE_CHECKING, Generic, Iterable, TypeVar
|
||||
from typing import TYPE_CHECKING, Any, Generic, Iterable, TypeVar, override
|
||||
|
||||
from .log import ERR, OFF, log, parse_log_level
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
import copy
|
||||
|
||||
from functools import cached_property
|
||||
from typing import override, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, override
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import urllib.parse
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Any, override, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Any, override
|
||||
|
||||
from ...Distro import Distro as Base
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ from __future__ import annotations
|
|||
|
||||
import os
|
||||
|
||||
from typing import Any, override, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Any, override
|
||||
|
||||
from ...Distro import Distro as Base
|
||||
from ...log import NOTICE, log
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Any, override, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Any, override
|
||||
|
||||
from ..FileContext import FileContext as Base
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ from __future__ import annotations
|
|||
|
||||
import os
|
||||
|
||||
from typing import Any, override, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Any, override
|
||||
|
||||
from ...base import InputMode
|
||||
from ...util import run_cmd
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Any, override, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Any, override
|
||||
|
||||
# Tolerate missing paramiko imports. jw-pkg is designed to work with what it
|
||||
# finds.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import pkgutil
|
||||
|
||||
from importlib import import_module
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,8 @@ import re
|
|||
import sys
|
||||
import syslog
|
||||
|
||||
from enum import Flag, auto
|
||||
|
||||
from datetime import datetime
|
||||
from enum import Flag, auto
|
||||
from os.path import basename
|
||||
from typing import TYPE_CHECKING, cast, override
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Any, TYPE_CHECKING, Collection, Iterable, cast
|
||||
from typing import TYPE_CHECKING, Any, Collection, Iterable, cast
|
||||
|
||||
from ..base import InputMode
|
||||
from ..Package import Package
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ from .Uri import Uri
|
|||
|
||||
if TYPE_CHECKING:
|
||||
from argparse import Namespace
|
||||
|
||||
from .ExecContext import ExecContext
|
||||
from .FileContext import FileContext
|
||||
from .ProcFilter import ProcFilter, ProcPipeline
|
||||
|
|
|
|||
Loading…
Reference in a new issue