(sources: list[BuildSource], ctx: ServerContext)
| 312 | |
| 313 | |
| 314 | def setup_worker_manager(sources: list[BuildSource], ctx: ServerContext) -> BuildManager | None: |
| 315 | data_dir = os.path.dirname(os.path.dirname(__file__)) |
| 316 | # This is used for testing only now. |
| 317 | alt_lib_path = os.environ.get("MYPY_ALT_LIB_PATH") |
| 318 | search_paths = compute_search_paths(sources, ctx.options, data_dir, alt_lib_path) |
| 319 | |
| 320 | source_set = BuildSourceSet(sources) |
| 321 | try: |
| 322 | plugin, snapshot = load_plugins(ctx.options, ctx.errors, sys.stdout, []) |
| 323 | except CompileError: |
| 324 | # CompileError while importing plugins will be reported by the coordinator. |
| 325 | return None |
| 326 | |
| 327 | # Process the rest of the options when plugins are loaded. |
| 328 | options = ctx.options |
| 329 | options.disable_error_code = ctx.disable_error_code |
| 330 | options.enable_error_code = ctx.enable_error_code |
| 331 | options.process_error_codes(error_callback=lambda msg: None) |
| 332 | |
| 333 | def flush_errors(filename: str | None, new_messages: list[str], is_serious: bool) -> None: |
| 334 | # We never flush errors in the worker, we send them back to coordinator. |
| 335 | pass |
| 336 | |
| 337 | try: |
| 338 | return BuildManager( |
| 339 | data_dir, |
| 340 | search_paths, |
| 341 | ignore_prefix=os.getcwd(), |
| 342 | source_set=source_set, |
| 343 | reports=None, |
| 344 | options=options, |
| 345 | version_id=__version__, |
| 346 | plugin=plugin, |
| 347 | plugins_snapshot=snapshot, |
| 348 | errors=ctx.errors, |
| 349 | error_formatter=None if options.output is None else OUTPUT_CHOICES.get(options.output), |
| 350 | flush_errors=flush_errors, |
| 351 | fscache=ctx.fscache, |
| 352 | stdout=sys.stdout, |
| 353 | stderr=sys.stderr, |
| 354 | parallel_worker=True, |
| 355 | ) |
| 356 | except CompileError: |
| 357 | return None |
| 358 | |
| 359 | |
| 360 | def console_entry() -> None: |
no test coverage detected
searching dependent graphs…