Repository navigation
Conversation
Partial protocol checks can skip incompatible members and therefore must not populate the full subtype cache. Add regression tests for inference against a union of callback protocols in both call orders. Fixes python#22151.
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: scipy-stubs (https://github.com/scipy/scipy-stubs)
- tests/misc/test_submodules_empty.pyi:3: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #22151.
is_protocol_implementation(..., skip=[...])checks only a subset of protocol members, but cached successful checks as full subtype results. During inference against a union of callback protocols, skipping__call__could therefore pollute the cache forbuiltins.function, causing a later call to inferNeverdepending on which call was checked first.Only record a subtype cache entry when no members were skipped. Add data-driven regression tests for both call orders; both fail on the original code and infer the expected
intandstrwith this change.Validation on Windows with Python 3.11.9:
python runtests.py self self-packaging: passed.python runtests.py lint: all 13 hooks passed.python runtests.py pytest-fast pytest-cmdline pytest-slow: 13,171 tests passed after the retry below, with 680 skipped, 9 expected failures, and 46 subtests passed.taskkill;python runtests.py testDaemonStatusKillRestartRecheckpassed when retried with normal process permissions.git diff --check: passed.