summaryrefslogtreecommitdiffstats
path: root/pre_commit_hooks/check_builtin_literals.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-06-19 07:03:36 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-06-19 07:03:44 +0000
commit9262e31316a16180044e0e28a2740238f8aef5c4 (patch)
tree49b2bc070018965707ec237623da9932c880fae4 /pre_commit_hooks/check_builtin_literals.py
parentAdding debian version 4.1.0-1. (diff)
downloadpre-commit-hooks-9262e31316a16180044e0e28a2740238f8aef5c4.tar.xz
pre-commit-hooks-9262e31316a16180044e0e28a2740238f8aef5c4.zip
Merging upstream version 4.3.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pre_commit_hooks/check_builtin_literals.py')
-rw-r--r--pre_commit_hooks/check_builtin_literals.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/pre_commit_hooks/check_builtin_literals.py b/pre_commit_hooks/check_builtin_literals.py
index 3fbae3e..d3054aa 100644
--- a/pre_commit_hooks/check_builtin_literals.py
+++ b/pre_commit_hooks/check_builtin_literals.py
@@ -1,10 +1,9 @@
+from __future__ import annotations
+
import argparse
import ast
-from typing import List
from typing import NamedTuple
-from typing import Optional
from typing import Sequence
-from typing import Set
BUILTIN_TYPES = {
@@ -27,10 +26,10 @@ class Call(NamedTuple):
class Visitor(ast.NodeVisitor):
def __init__(
self,
- ignore: Optional[Sequence[str]] = None,
+ ignore: Sequence[str] | None = None,
allow_dict_kwargs: bool = True,
) -> None:
- self.builtin_type_calls: List[Call] = []
+ self.builtin_type_calls: list[Call] = []
self.ignore = set(ignore) if ignore else set()
self.allow_dict_kwargs = allow_dict_kwargs
@@ -56,9 +55,9 @@ class Visitor(ast.NodeVisitor):
def check_file(
filename: str,
- ignore: Optional[Sequence[str]] = None,
+ ignore: Sequence[str] | None = None,
allow_dict_kwargs: bool = True,
-) -> List[Call]:
+) -> list[Call]:
with open(filename, 'rb') as f:
tree = ast.parse(f.read(), filename=filename)
visitor = Visitor(ignore=ignore, allow_dict_kwargs=allow_dict_kwargs)
@@ -66,11 +65,11 @@ def check_file(
return visitor.builtin_type_calls
-def parse_ignore(value: str) -> Set[str]:
+def parse_ignore(value: str) -> set[str]:
return set(value.split(','))
-def main(argv: Optional[Sequence[str]] = None) -> int:
+def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='*')
parser.add_argument('--ignore', type=parse_ignore, default=set())