From bf5f6fe39b023dbfb2ed782614e2705a665a45f8 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 26 Oct 2023 14:55:02 -0700 Subject: [PATCH] =?UTF-8?q?Convert=20type=20comments=20to=20Python=20?= =?UTF-8?q?=E2=89=A5=203.6=20variable=20annotations.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Anders Kaseorg --- zulint/command.py | 16 +++++++++------- zulint/lister.py | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/zulint/command.py b/zulint/command.py index b0d8d44..e117d3c 100644 --- a/zulint/command.py +++ b/zulint/command.py @@ -67,7 +67,9 @@ def split_arg_into_list(arg: str) -> List[str]: return [linter for linter in arg.split(",")] -run_parallel_functions = weakref.WeakValueDictionary() # type: weakref.WeakValueDictionary[int, Callable[[], int]] +run_parallel_functions: "weakref.WeakValueDictionary[int, Callable[[], int]]" = ( + weakref.WeakValueDictionary() +) def run_parallel_worker(item: Tuple[str, int]) -> Tuple[str, int]: @@ -106,14 +108,14 @@ def run_parallel( class LinterConfig: - lint_functions = {} # type: Dict[str, Callable[[], int]] - lint_descriptions = {} # type: Dict[str, str] - fixable_linters = set() # type: Set[str] + lint_functions: Dict[str, Callable[[], int]] = {} + lint_descriptions: Dict[str, str] = {} + fixable_linters: Set[str] = set() def __init__(self, args: argparse.Namespace) -> None: self.args = args - self.by_lang = {} # type: Dict[str, List[str]] - self.groups = {} # type: Mapping[str, Sequence[str]] + self.by_lang: Dict[str, List[str]] = {} + self.groups: Mapping[str, Sequence[str]] = {} def list_files( self, @@ -176,7 +178,7 @@ def external_linter( color = next(colors) def run_linter() -> int: - targets = [] # type: List[str] + targets: List[str] = [] if len(target_langs) != 0: targets = [ target for lang in target_langs for target in self.by_lang[lang] diff --git a/zulint/lister.py b/zulint/lister.py index a65d321..7fc2646 100755 --- a/zulint/lister.py +++ b/zulint/lister.py @@ -123,8 +123,8 @@ def list_files( # throw away non-files (like symlinks) files = [f for f in files if not os.path.islink(f) and os.path.isfile(f)] - result_dict = defaultdict(list) # type: Dict[str, List[str]] - result_list = [] # type: List[str] + result_dict: Dict[str, List[str]] = defaultdict(list) + result_list: List[str] = [] for fpath in files: # this will take a long time if exclude is very large