Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up pythoneval tests #16559

Merged
merged 1 commit into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,9 @@ def check_overlapping_overloads(self, defn: OverloadedFuncDef) -> None:
# At this point we should have set the impl already, and all remaining
# items are decorators

if self.msg.errors.file in self.msg.errors.ignored_files:
if self.msg.errors.file in self.msg.errors.ignored_files or (
self.is_typeshed_stub and self.options.test_env
):
# This is a little hacky, however, the quadratic check here is really expensive, this
# method has no side effects, so we should skip it if we aren't going to report
# anything. In some other places we swallow errors in stubs, but this error is very
Expand Down
2 changes: 2 additions & 0 deletions mypy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,8 @@ def add_invertible_flag(
parser.add_argument("--dump-graph", action="store_true", help=argparse.SUPPRESS)
# --semantic-analysis-only does exactly that.
parser.add_argument("--semantic-analysis-only", action="store_true", help=argparse.SUPPRESS)
# Some tests use this to tell mypy that we are running a test.
parser.add_argument("--test-env", action="store_true", help=argparse.SUPPRESS)
# --local-partial-types disallows partial types spanning module top level and a function
# (implicitly defined in fine-grained incremental mode)
parser.add_argument("--local-partial-types", action="store_true", help=argparse.SUPPRESS)
Expand Down
4 changes: 4 additions & 0 deletions mypy/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,10 @@ def __init__(self) -> None:
# Use stub builtins fixtures to speed up tests
self.use_builtins_fixtures = False

# This should only be set when running certain mypy tests.
# Use this sparingly to avoid tests diverging from non-test behavior.
self.test_env = False

# -- experimental options --
self.shadow_file: list[list[str]] | None = None
self.show_column_numbers: bool = False
Expand Down
1 change: 1 addition & 0 deletions mypy/test/testpythoneval.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def test_python_evaluation(testcase: DataDrivenTestCase, cache_dir: str) -> None
"--hide-error-codes",
"--allow-empty-bodies",
"--force-uppercase-builtins",
"--test-env", # Speeds up some checks
]
interpreter = python3_path
mypy_cmdline.append(f"--python-version={'.'.join(map(str, PYTHON3_VERSION))}")
Expand Down