Initialize the server with the desired mypy flags.
(self, options: Options, status_file: str, timeout: int | None = None)
| 174 | # serve() is called in the grandchild (by daemonize()). |
| 175 | |
| 176 | def __init__(self, options: Options, status_file: str, timeout: int | None = None) -> None: |
| 177 | """Initialize the server with the desired mypy flags.""" |
| 178 | self.options = options |
| 179 | # Snapshot the options info before we muck with it, to detect changes |
| 180 | self.options_snapshot = options.snapshot() |
| 181 | self.timeout = timeout |
| 182 | self.fine_grained_manager: FineGrainedBuildManager | None = None |
| 183 | |
| 184 | if os.path.isfile(status_file): |
| 185 | os.unlink(status_file) |
| 186 | |
| 187 | self.fscache = FileSystemCache() |
| 188 | |
| 189 | options.raise_exceptions = True |
| 190 | options.incremental = True |
| 191 | options.fine_grained_incremental = True |
| 192 | options.show_traceback = True |
| 193 | if options.use_fine_grained_cache: |
| 194 | # Using fine_grained_cache implies generating and caring |
| 195 | # about the fine grained cache |
| 196 | options.cache_fine_grained = True |
| 197 | else: |
| 198 | options.cache_dir = os.devnull |
| 199 | # Fine-grained incremental doesn't support general partial types |
| 200 | # (details in https://github.com/python/mypy/issues/4492) |
| 201 | options.local_partial_types = True |
| 202 | self.status_file = status_file |
| 203 | |
| 204 | # Since the object is created in the parent process we can check |
| 205 | # the output terminal options here. |
| 206 | self.formatter = FancyFormatter(sys.stdout, sys.stderr, options.hide_error_codes) |
| 207 | |
| 208 | def _response_metadata(self) -> dict[str, str]: |
| 209 | py_version = f"{self.options.python_version[0]}_{self.options.python_version[1]}" |
nothing calls this directly
no test coverage detected