From c71fadb18ca9f23d8a6474c0155404b49e21c30e Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 16 Feb 2019 18:36:14 -0800 Subject: [PATCH] Improve a few mypy type annotations --- src/flake8/checker.py | 4 ++-- src/flake8/main/application.py | 5 +++-- src/flake8/utils.py | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/flake8/checker.py b/src/flake8/checker.py index 138bb4f..2680ed3 100644 --- a/src/flake8/checker.py +++ b/src/flake8/checker.py @@ -5,7 +5,7 @@ import logging import signal import sys import tokenize -from typing import List, Optional +from typing import List, Optional, Tuple try: import multiprocessing @@ -247,7 +247,7 @@ class Manager(object): LOG.info("Checking %d files", len(self.checkers)) def report(self): - # type: () -> (int, int) + # type: () -> Tuple[int, int] """Report all of the errors found in the managed file checkers. This iterates over each of the checkers and reports the errors sorted diff --git a/src/flake8/main/application.py b/src/flake8/main/application.py index 4515d13..6e8ddaf 100644 --- a/src/flake8/main/application.py +++ b/src/flake8/main/application.py @@ -4,7 +4,7 @@ from __future__ import print_function import logging import sys import time -from typing import List, Optional, Sequence +from typing import List, Optional import flake8 from flake8 import checker @@ -99,6 +99,7 @@ class Application(object): self.parsed_diff = {} def parse_preliminary_options_and_args(self, argv=None): + # type: (Optional[List[str]]) -> None """Get preliminary options and args from CLI, pre-plugin-loading. We need to know the values of a few standard options and args now, so @@ -347,7 +348,7 @@ class Application(object): self.formatter.show_statistics(self.guide.stats) def initialize(self, argv): - # type: (Sequence[str]) -> None + # type: (Optional[List[str]]) -> None """Initialize the application to be run. This finds the plugins, registers their options, and parses the diff --git a/src/flake8/utils.py b/src/flake8/utils.py index 6048132..b95d4db 100644 --- a/src/flake8/utils.py +++ b/src/flake8/utils.py @@ -8,8 +8,8 @@ import platform import re import sys import tokenize -from typing import Callable, Dict, Generator, List, Pattern, Sequence, Tuple -from typing import Union +from typing import Callable, Dict, Generator, List, Pattern, Sequence, Set +from typing import Tuple, Union from flake8 import exceptions @@ -217,7 +217,7 @@ def stdin_get_value(): def parse_unified_diff(diff=None): - # type: (str) -> List[str] + # type: (str) -> Dict[str, Set[int]] """Parse the unified diff passed on stdin. :returns: