Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix parallel execution collecting a SyntaxError #1410

Merged
merged 1 commit into from
Oct 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]]:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't have a great way of testing the parallel mode in integration so I leveraged the type checker as a "test" instead

"""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