Use dmypy instead of mypy in lintrunner (#118475)

Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/118475
Approved by: https://github.com/suo
ghstack dependencies: #118414, #118418, #118432, #118467, #118468, #118469
This commit is contained in:
Edward Z. Yang
2024-01-27 19:39:23 -08:00
committed by PyTorch MergeBot
parent cad79bd0bb
commit ecca533872
2 changed files with 8 additions and 3 deletions

View File

@ -49,7 +49,9 @@ from torchgen.model import (
from torchgen.utils import concatMap, IDENT_REGEX, split_name_params
from torchgen.yaml_utils import YamlLoader
_GLOBAL_LOAD_DERIVATIVE_CACHE = {}
DerivativeRet = Tuple[Dict[FunctionSchema, Dict[str, DifferentiabilityInfo]], Set[str]]
_GLOBAL_LOAD_DERIVATIVE_CACHE: Dict[Tuple[str, str], DerivativeRet] = {}
_VALID_AUTOGRAD_KEYS = set(AUTOGRAD_KEYS)
@ -94,7 +96,7 @@ def add_view_copy_derivatives(
def load_derivatives(
derivatives_yaml_path: str, native_yaml_path: str, tags_yaml_path: str
) -> Tuple[Dict[FunctionSchema, Dict[str, DifferentiabilityInfo]], Set[str]]:
) -> DerivativeRet:
# Do some caching as this is a deterministic function
global _GLOBAL_LOAD_DERIVATIVE_CACHE
key = (derivatives_yaml_path, native_yaml_path)

View File

@ -122,9 +122,12 @@ def check_files(
retries: int,
code: str,
) -> List[LintMessage]:
# dmypy has a bug where it won't pick up changes if you pass it absolute
# file names, see https://github.com/python/mypy/issues/16768
filenames = [os.path.relpath(f) for f in filenames]
try:
proc = run_command(
[sys.executable, "-mmypy", f"--config={config}"] + filenames,
["dmypy", "run", "--", f"--config={config}"] + filenames,
extra_env={},
retries=retries,
)