1919from mypy_primer .globals import ctx
2020from mypy_primer .utils import BIN_DIR , Style , debug_print , run
2121
22+ extra_dataclass_args = {"kw_only" : True } if sys .version_info >= (3 , 10 ) else {}
2223
23- @dataclass (frozen = True )
24+
25+ @dataclass (frozen = True , ** extra_dataclass_args )
2426class Project :
2527 location : str
2628 mypy_cmd : str
2729 revision : str | None = None
30+ min_python_version : tuple [int , int ] | None = None
2831 pip_cmd : str | None = None
2932 # if expected_success, there is a recent version of mypy which passes cleanly
3033 expected_mypy_success : bool = False
@@ -34,6 +37,26 @@ class Project:
3437 pyright_cmd : str | None = None
3538 expected_pyright_success : bool = False
3639
40+ # custom __repr__ that omits defaults.
41+ def __repr__ (self ) -> str :
42+ result = f"Project(location={ self .location !r} , mypy_cmd={ self .mypy_cmd !r} "
43+ if self .pyright_cmd :
44+ result += f", pyright_cmd={ self .pyright_cmd !r} "
45+ if self .pip_cmd :
46+ result += f", pip_cmd={ self .pip_cmd !r} "
47+ if self .expected_mypy_success :
48+ result += f", expected_mypy_success={ self .expected_mypy_success !r} "
49+ if self .expected_pyright_success :
50+ result += f", expected_pyright_success={ self .expected_pyright_success !r} "
51+ if self .mypy_cost != 3 :
52+ result += f", mypy_cost={ self .mypy_cost !r} "
53+ if self .revision :
54+ result += f", revision={ self .revision !r} "
55+ if self .min_python_version :
56+ result += f", min_python_version={ self .min_python_version !r} "
57+ result += ")"
58+ return result
59+
3760 @property
3861 def name (self ) -> str :
3962 return Path (self .location ).name
@@ -324,7 +347,7 @@ def format_concise(self) -> str:
324347 ret += (
325348 f": typechecking got { runtime_ratio :.2f} x { speed } "
326349 f"({ self .old_result .runtime :.1f} s -> { self .new_result .runtime :.1f} s)\n "
327- f "(Performance measurements are based on a single noisy sample)"
350+ "(Performance measurements are based on a single noisy sample)"
328351 )
329352 if self .diff :
330353 ret += "\n " + self .diff
0 commit comments