Check a list of files, triggering a restart if needed.
(
self,
version: str,
args: Sequence[str],
export_types: bool,
is_tty: bool,
terminal_width: int,
)
| 313 | return {} |
| 314 | |
| 315 | def cmd_run( |
| 316 | self, |
| 317 | version: str, |
| 318 | args: Sequence[str], |
| 319 | export_types: bool, |
| 320 | is_tty: bool, |
| 321 | terminal_width: int, |
| 322 | ) -> dict[str, object]: |
| 323 | """Check a list of files, triggering a restart if needed.""" |
| 324 | stderr = io.StringIO() |
| 325 | stdout = io.StringIO() |
| 326 | try: |
| 327 | # Process options can exit on improper arguments, so we need to catch that and |
| 328 | # capture stderr so the client can report it |
| 329 | with redirect_stderr(stderr): |
| 330 | with redirect_stdout(stdout): |
| 331 | sources, options = mypy.main.process_options( |
| 332 | ["-i"] + list(args), |
| 333 | require_targets=True, |
| 334 | server_options=True, |
| 335 | fscache=self.fscache, |
| 336 | program="mypy-daemon", |
| 337 | header=argparse.SUPPRESS, |
| 338 | ) |
| 339 | # Signal that we need to restart if the options have changed |
| 340 | if not options.compare_stable(self.options_snapshot): |
| 341 | return {"restart": "configuration changed"} |
| 342 | if __version__ != version: |
| 343 | return {"restart": "mypy version changed"} |
| 344 | if self.fine_grained_manager: |
| 345 | manager = self.fine_grained_manager.manager |
| 346 | start_plugins_snapshot = manager.plugins_snapshot |
| 347 | _, current_plugins_snapshot = mypy.build.load_plugins( |
| 348 | options, manager.errors, sys.stdout, extra_plugins=() |
| 349 | ) |
| 350 | if current_plugins_snapshot != start_plugins_snapshot: |
| 351 | return {"restart": "plugins changed"} |
| 352 | except InvalidSourceList as err: |
| 353 | return {"out": "", "err": str(err), "status": 2} |
| 354 | except SystemExit as e: |
| 355 | return {"out": stdout.getvalue(), "err": stderr.getvalue(), "status": e.code} |
| 356 | return self.check(sources, export_types, is_tty, terminal_width) |
| 357 | |
| 358 | def cmd_check( |
| 359 | self, files: Sequence[str], export_types: bool, is_tty: bool, terminal_width: int |
nothing calls this directly
no test coverage detected