Don't use mypy daemon in CI (#145961)

This is an attempt to fix flaky mypy errors in CI that look like:

```
dmypy status --verbose
connection_name         : /var/folders/rf/qrn1jkgj0b9_tcznwp8ck46w0000gn/T/tmpjoqsid7_/dmypy.sock
pid                     :      32233
error                   :  timed out
Daemon is stuck; consider /Users/zainr/pytorch/venv/bin/dmypy kill
```

"Fix" it by not using the daemon at all, since it doesn't actually provide any perf benefits in CI.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/145961
Approved by: https://github.com/malfet
This commit is contained in:
Zain Rizvi 2025-01-29 21:15:29 +00:00 committed by PyTorch MergeBot
parent 40ccb7a86d
commit a6e3f294f1

View file

@ -118,6 +118,10 @@ def check_mypy_installed(code: str) -> list[LintMessage]:
]
def in_github_actions() -> bool:
return bool(os.getenv("GITHUB_ACTIONS"))
def check_files(
filenames: list[str],
config: str,
@ -128,8 +132,11 @@ def check_files(
# file names, see https://github.com/python/mypy/issues/16768
filenames = [os.path.relpath(f) for f in filenames]
try:
mypy_commands = ["dmypy", "run", "--"]
if in_github_actions():
mypy_commands = ["mypy"]
proc = run_command(
["dmypy", "run", "--", f"--config={config}"] + filenames,
[*mypy_commands, f"--config={config}"] + filenames,
extra_env={},
retries=retries,
)