Skip to content

Commit

Permalink
Convert type comments to Python ≥ 3.6 variable annotations.
Browse files Browse the repository at this point in the history
Signed-off-by: Anders Kaseorg <[email protected]>
  • Loading branch information
andersk committed Oct 26, 2023
1 parent 0695485 commit bf5f6fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
16 changes: 9 additions & 7 deletions zulint/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions zulint/lister.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bf5f6fe

Please sign in to comment.