diff options
author | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2023-10-25 00:55:17 +0200 |
---|---|---|
committer | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2023-10-25 01:10:21 +0200 |
commit | d516cf83ed2da86dfefb395cd46f8a894907b88e (patch) | |
tree | fc6f864676dc1820a705583c9f518b694dd8a635 /test/lint | |
parent | d53400e75e2a4573229dba7f1a0da88eb936811c (diff) | |
download | bitcoin-d516cf83ed2da86dfefb395cd46f8a894907b88e.tar.xz |
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
Diffstat (limited to 'test/lint')
-rwxr-xr-x | test/lint/lint-files.py | 4 | ||||
-rwxr-xr-x | test/lint/lint-include-guards.py | 3 |
2 files changed, 3 insertions, 4 deletions
diff --git a/test/lint/lint-files.py b/test/lint/lint-files.py index f2b5db681b..86fe727b06 100755 --- a/test/lint/lint-files.py +++ b/test/lint/lint-files.py @@ -11,7 +11,7 @@ import os import re import sys from subprocess import check_output -from typing import Dict, Optional, NoReturn +from typing import Optional, NoReturn CMD_TOP_LEVEL = ["git", "rev-parse", "--show-toplevel"] CMD_ALL_FILES = ["git", "ls-files", "-z", "--full-name", "--stage"] @@ -69,7 +69,7 @@ class FileMeta(object): return None -def get_git_file_metadata() -> Dict[str, FileMeta]: +def get_git_file_metadata() -> dict[str, FileMeta]: ''' Return a dictionary mapping the name of all files in the repository to git tree metadata. ''' diff --git a/test/lint/lint-include-guards.py b/test/lint/lint-include-guards.py index 48b918e9da..291e528c1d 100755 --- a/test/lint/lint-include-guards.py +++ b/test/lint/lint-include-guards.py @@ -11,7 +11,6 @@ Check include guards. import re import sys from subprocess import check_output -from typing import List HEADER_ID_PREFIX = 'BITCOIN_' @@ -28,7 +27,7 @@ EXCLUDE_FILES_WITH_PREFIX = ['contrib/devtools/bitcoin-tidy', 'src/test/fuzz/FuzzedDataProvider.h'] -def _get_header_file_lst() -> List[str]: +def _get_header_file_lst() -> list[str]: """ Helper function to get a list of header filepaths to be checked for include guards. """ |