test: use built-in collection types for type hints (Python 3.9 / PEP 585)

Since Python 3.9, type hinting has become a little less awkward, as for
collection types one doesn't need to import the corresponding
capitalized types (`Dict`, `List`, `Set`, `Tuple`, ...) anymore, but can
use the built-in types directly. [1] [2]
This commit applies the replacement for all Python scripts (i.e. in the
contrib and test folders) for the basic types:
    - typing.Dict  -> dict
    - typing.List  -> list
    - typing.Set   -> set
    - typing.Tuple -> tuple

[1] https://docs.python.org/3.9/whatsnew/3.9.html#type-hinting-generics-in-standard-collections
[2] https://peps.python.org/pep-0585/#implementation for a list of type
This commit is contained in:
Sebastian Falbesoner
2023-10-25 00:55:17 +02:00
parent d53400e75e
commit d516cf83ed
18 changed files with 76 additions and 88 deletions

View File

@ -11,7 +11,7 @@ import sys
from io import BytesIO
import json
from pathlib import Path
from typing import Any, List, Optional
from typing import Any, Optional
sys.path.append(os.path.join(os.path.dirname(__file__), '../../test/functional'))
@ -92,7 +92,7 @@ def to_jsonable(obj: Any) -> Any:
return obj
def process_file(path: str, messages: List[Any], recv: bool, progress_bar: Optional[ProgressBar]) -> None:
def process_file(path: str, messages: list[Any], recv: bool, progress_bar: Optional[ProgressBar]) -> None:
with open(path, 'rb') as f_in:
if progress_bar:
bytes_read = 0
@ -188,7 +188,7 @@ def main():
output = Path.cwd() / Path(args.output) if args.output else False
use_progress_bar = (not args.no_progress_bar) and sys.stdout.isatty()
messages = [] # type: List[Any]
messages = [] # type: list[Any]
if use_progress_bar:
total_size = sum(capture.stat().st_size for capture in capturepaths)
progress_bar = ProgressBar(total_size)