Skip to content

Commit 1980c5e

Browse files
JayBazuziisidorereyr-dev
committed
! F tidy upgrades to Python 3.10
The linter cleaned a bunch of stuff In test_verify we fixed the import of `List`. Co-Authored-By: Llewellyn Falco <llewellyn.falco@gmail.com> Co-Authored-By: reyr-dev <236299828+reyr-dev@users.noreply.github.com>
1 parent ffd2db3 commit 1980c5e

69 files changed

Lines changed: 265 additions & 289 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎approval_utilities/list_utils.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
from typing import Any, Callable, Iterable, Optional
1+
from collections.abc import Callable, Iterable
2+
from typing import Any
23

34

4-
def format_list(
5-
alist: Iterable[Any], formatter: Optional[Callable], header: str
6-
) -> str:
5+
def format_list(alist: Iterable[Any], formatter: Callable | None, header: str) -> str:
76
if formatter is None:
87
formatter = FormatLineItem().print_item
98
text = (header + "\n\n") if header else ""

‎approval_utilities/utilities/deprecated.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import functools
22
import warnings
3-
from typing import Callable
3+
from collections.abc import Callable
44

55

66
def deprecated(reason: str) -> Callable:

‎approval_utilities/utilities/exceptions/exception_collector.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Any, Callable, List, Sequence
1+
from collections.abc import Callable, Sequence
2+
from typing import Any
23

34
from approval_utilities.utilities.exceptions.multiple_exceptions import (
45
MultipleExceptions,
@@ -7,7 +8,7 @@
78

89
class ExceptionCollector:
910
def __init__(self) -> None:
10-
self._exceptions: List[Exception] = []
11+
self._exceptions: list[Exception] = []
1112

1213
def gather(self, code_to_execute: Callable[[], Any]) -> None:
1314
try:

‎approval_utilities/utilities/exceptions/multiple_exceptions.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Sequence
1+
from collections.abc import Sequence
22

33
from approval_utilities.utilities.exceptions.exception_utils import to_string
44

‎approval_utilities/utilities/logger/logging_instance.py‎

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import datetime
22
import inspect
33
import traceback
4+
from collections.abc import Callable, Iterable
45
from types import TracebackType
5-
from typing import Any, Callable, ContextManager, Iterable, Optional, Type, Union
6+
from typing import Any, ContextManager
67

78
from approval_utilities.utilities.exceptions.exception_utils import to_string
89
from approval_utilities.utilities.stack_frame_utilities import get_class_name_for_frame
@@ -31,7 +32,7 @@ class LoggingInstance:
3132
def __init__(self) -> None:
3233
self.log_stack_traces = True
3334
self.toggles = Toggles(True)
34-
self.previous_timestamp: Optional[datetime.datetime] = None
35+
self.previous_timestamp: datetime.datetime | None = None
3536
self.logger: Callable[[str], None] = lambda t: print(t, end="")
3637
self.tabbing: int = 0
3738
self.counter = 0
@@ -55,17 +56,17 @@ def __enter__(self) -> None:
5556

5657
def __exit__(
5758
self,
58-
exc_type: Optional[Type[BaseException]],
59-
exc_val: Optional[BaseException],
60-
exc_tb: Optional[TracebackType],
59+
exc_type: type[BaseException] | None,
60+
exc_val: BaseException | None,
61+
exc_tb: TracebackType | None,
6162
) -> None:
6263
self.log.tabbing -= 1
6364

6465
return Indent(self)
6566

6667
def use_markers(
6768
self,
68-
parameter_text: Optional[Union[str, Callable[[], str]]] = None,
69+
parameter_text: str | Callable[[], str] | None = None,
6970
additional_stack: int = 0,
7071
) -> ContextManager[None]:
7172
class Nothing:
@@ -74,9 +75,9 @@ def __enter__(self) -> None:
7475

7576
def __exit__(
7677
self,
77-
exc_type: Optional[type],
78-
exc_val: Optional[BaseException],
79-
exc_tb: Optional[TracebackType],
78+
exc_type: type | None,
79+
exc_val: BaseException | None,
80+
exc_tb: TracebackType | None,
8081
) -> None:
8182
pass
8283

@@ -98,9 +99,9 @@ def __enter__(self) -> None:
9899

99100
def __exit__(
100101
self,
101-
exc_type: Optional[type],
102-
exc_val: Optional[BaseException],
103-
exc_tb: Optional[TracebackType],
102+
exc_type: type | None,
103+
exc_val: BaseException | None,
104+
exc_tb: TracebackType | None,
104105
) -> None:
105106
self.log.tabbing = self.log.tabbing - 1
106107
expected = f"<- out: {self.method_name}({self.get_parameters(True)})"
@@ -201,8 +202,8 @@ def message(self, message: str) -> None:
201202

202203
def warning(
203204
self,
204-
text: Union[str, BaseException] = "",
205-
exception: Optional[BaseException] = None,
205+
text: str | BaseException = "",
206+
exception: BaseException | None = None,
206207
) -> None:
207208
if isinstance(text, Exception):
208209
temp = ""

‎approval_utilities/utilities/logger/simple_logger.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import threading
2-
from typing import Any, Callable, ContextManager, Optional, Union
2+
from collections.abc import Callable
3+
from typing import Any, ContextManager
34

45
from approval_utilities.utilities.logger.logging_instance import LoggingInstance
56
from approval_utilities.utilities.string_wrapper import StringWrapper
@@ -24,7 +25,7 @@ def log_to_string(log_separate_threads: bool = True) -> StringWrapper:
2425

2526
@staticmethod
2627
def use_markers(
27-
parameter_text: Optional[Union[str, Callable[[], str]]] = None,
28+
parameter_text: str | Callable[[], str] | None = None,
2829
) -> ContextManager[None]:
2930
return SimpleLogger._wrapper.get().use_markers(
3031
parameter_text, additional_stack=1
@@ -56,7 +57,7 @@ def message(message: str) -> None:
5657

5758
@staticmethod
5859
def warning(
59-
text: Union[str, BaseException] = "", exception: Optional[BaseException] = None
60+
text: str | BaseException = "", exception: BaseException | None = None
6061
) -> None:
6162
SimpleLogger._wrapper.get().warning(text, exception)
6263

‎approval_utilities/utilities/map_reduce.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import itertools
2-
from typing import Any, Callable, Dict, Generator, Sequence
2+
from collections.abc import Callable, Generator, Sequence
3+
from typing import Any
34

45

56
def first(sequence: Sequence[Any], predicate: Callable[[Any], bool]) -> Any:
67
matching = filter(predicate, sequence)
78
return next(matching, None)
89

910

10-
def product_dict(**kwargs: Sequence[Any]) -> Generator[Dict[str, Any], None, None]:
11+
def product_dict(**kwargs: Sequence[Any]) -> Generator[dict[str, Any], None, None]:
1112
"""
1213
Similar to `itertools.product`, but the resulting combinations retain the names.
1314
"""

‎approval_utilities/utilities/markdown_table.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import TYPE_CHECKING, Any, Callable, Iterable
1+
from collections.abc import Callable, Iterable
2+
from typing import TYPE_CHECKING, Any
23

34
from typing_extensions import override
45

‎approval_utilities/utilities/multiline_string_utils.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import textwrap
2-
from typing import Optional
32

43

5-
def remove_indentation_from(text: Optional[str]) -> str:
4+
def remove_indentation_from(text: str | None) -> str:
65
if not text:
76
return ""
87
cleaned = textwrap.dedent(text + "|")
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import subprocess
2-
from typing import List
32

43

5-
def run_command(command_array: List[str]) -> None:
4+
def run_command(command_array: list[str]) -> None:
65
with subprocess.Popen(command_array):
76
pass

0 commit comments

Comments
 (0)