Skip to content

Commit cf845c1

Browse files
authored
Minor fixes in parallel checking (#21319)
Not adding tests for these fixes, as they are covered by running `cmdline` tests in parallel mode.
1 parent 1e96fb7 commit cf845c1

2 files changed

Lines changed: 29 additions & 20 deletions

File tree

mypy/build_worker/worker.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
)
4949
from mypy.cache import Tag, read_int_list, read_json
5050
from mypy.defaults import RECURSION_LIMIT, WORKER_CONNECTION_TIMEOUT, WORKER_IDLE_TIMEOUT
51+
from mypy.error_formatter import OUTPUT_CHOICES
5152
from mypy.errors import CompileError, ErrorInfo, Errors, report_internal_error
5253
from mypy.fscache import FileSystemCache
5354
from mypy.ipc import IPCException, IPCServer, ready_to_read, receive, send
@@ -319,24 +320,27 @@ def flush_errors(filename: str | None, new_messages: list[str], is_serious: bool
319320
# We never flush errors in the worker, we send them back to coordinator.
320321
pass
321322

322-
return BuildManager(
323-
data_dir,
324-
search_paths,
325-
ignore_prefix=os.getcwd(),
326-
source_set=source_set,
327-
reports=None,
328-
options=options,
329-
version_id=__version__,
330-
plugin=plugin,
331-
plugins_snapshot=snapshot,
332-
errors=ctx.errors,
333-
error_formatter=None,
334-
flush_errors=flush_errors,
335-
fscache=ctx.fscache,
336-
stdout=sys.stdout,
337-
stderr=sys.stderr,
338-
parallel_worker=True,
339-
)
323+
try:
324+
return BuildManager(
325+
data_dir,
326+
search_paths,
327+
ignore_prefix=os.getcwd(),
328+
source_set=source_set,
329+
reports=None,
330+
options=options,
331+
version_id=__version__,
332+
plugin=plugin,
333+
plugins_snapshot=snapshot,
334+
errors=ctx.errors,
335+
error_formatter=None if options.output is None else OUTPUT_CHOICES.get(options.output),
336+
flush_errors=flush_errors,
337+
fscache=ctx.fscache,
338+
stdout=sys.stdout,
339+
stderr=sys.stderr,
340+
parallel_worker=True,
341+
)
342+
except CompileError:
343+
return None
340344

341345

342346
def console_entry() -> None:

mypy/options.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,13 @@ def process_error_codes(self, *, error_callback: Callable[[str], Any]) -> None:
479479
if invalid_code_names_here:
480480
error_callback(f"Invalid error code(s): {', '.join(sorted(invalid_code_names_here))}")
481481

482-
self.disabled_error_codes |= {error_codes[code] for code in disabled_code_names}
483-
self.enabled_error_codes |= {error_codes[code] for code in enabled_code_names}
482+
# Ignore invalid error codes.
483+
self.disabled_error_codes |= {
484+
error_codes[code] for code in disabled_code_names if code in error_codes
485+
}
486+
self.enabled_error_codes |= {
487+
error_codes[code] for code in enabled_code_names if code in error_codes
488+
}
484489

485490
# Enabling an error code always overrides disabling
486491
self.disabled_error_codes -= self.enabled_error_codes

0 commit comments

Comments
 (0)