From 9262e31316a16180044e0e28a2740238f8aef5c4 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 19 Jun 2022 09:03:36 +0200 Subject: Merging upstream version 4.3.0. Signed-off-by: Daniel Baumann --- pre_commit_hooks/check_builtin_literals.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'pre_commit_hooks/check_builtin_literals.py') 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()) -- cgit v1.2.3