Skip to content

Commit

Permalink
Merge pull request #1410 from PyCQA/parallel-syntax-error
Browse files Browse the repository at this point in the history
fix parallel execution collecting a SyntaxError
  • Loading branch information
asottile committed Oct 11, 2021
2 parents d31c535 + aa54693 commit 0fac346
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/flake8/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
except ImportError:
multiprocessing = None # type: ignore

Results = List[Tuple[str, int, int, str, Optional[str]]]

LOG = logging.getLogger(__name__)

SERIAL_RETRY_ERRNOS = {
Expand Down Expand Up @@ -346,7 +348,7 @@ def __init__(self, filename, checks, options):
self.options = options
self.filename = filename
self.checks = checks
self.results: List[Tuple[str, int, int, str, Optional[str]]] = []
self.results: Results = []
self.statistics = {
"tokens": 0,
"logical lines": 0,
Expand Down Expand Up @@ -588,7 +590,7 @@ def process_tokens(self):
self.run_physical_checks(file_processor.lines[-1])
self.run_logical_checks()

def run_checks(self):
def run_checks(self) -> Tuple[str, Results, Dict[str, int]]:
"""Run checks against the file."""
assert self.processor is not None
try:
Expand All @@ -598,7 +600,7 @@ def run_checks(self):
code = "E902" if isinstance(e, tokenize.TokenError) else "E999"
row, column = self._extract_syntax_information(e)
self.report(code, row, column, f"{type(e).__name__}: {e.args[0]}")
return
return self.filename, self.results, self.statistics

logical_lines = self.processor.statistics["logical lines"]
self.statistics["logical lines"] = logical_lines
Expand Down

0 comments on commit 0fac346

Please sign in to comment.