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.*',
|
||||
|
|
|
|||
Loading…
Reference in a new issue