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:
Jan Lindemann 2026-08-09 15:40:50 +02:00
commit 5d77955ed9
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61
56 changed files with 109 additions and 67 deletions

View file

@ -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.*',

View file

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

View file

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

View file

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

View file

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

View file

@ -1,6 +1,6 @@
from __future__ import annotations
from typing import override, Any
from typing import Any, override
meta_tags = [
'name',

View file

@ -1,4 +1,5 @@
from __future__ import annotations
import abc
import re

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,6 +1,7 @@
from __future__ import annotations
import pkgutil
from importlib import import_module
from typing import TYPE_CHECKING

View file

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

View file

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

View file

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