[ty] Fix invalid-match-pattern false positives#23338
Merged
AlexWaygood merged 2 commits intomainfrom Feb 16, 2026
Merged
Conversation
Typing conformance resultsNo changes detected ✅ |
|
Memory usage reportMemory usage unchanged ✅ |
sharkdp
approved these changes
Feb 16, 2026
Contributor
sharkdp
left a comment
There was a problem hiding this comment.
Thank you!
I saw those ecosystem hits, but was too quickly in concluding that they would only go away once we statically understand these dynamic imports (and resolve to either the correct class type, or Any).
crates/ty_python_semantic/resources/mdtest/conditional/match.md
Outdated
Show resolved
Hide resolved
3ab0fe8 to
bcb0e68
Compare
Contributor
|
Thanks! I think I should have mentioned on the earlier PR that I hadn't looked at these diagnostics yet. |
Member
Author
No problem! Thanks for the PR! |
carljm
added a commit
that referenced
this pull request
Feb 16, 2026
* main: (43 commits) [`ruff`] Suppress diagnostic for strings with backslashes in interpolations before Python 3.12 (`RUF027`) (#21069) [flake8-bugbear] Fix B023 false positive for immediately-invoked lambdas (#23294) [ty] Add `Final` mdtests for loops and redeclaration (#23331) [`flake8-pyi`] Also check string annotations (`PYI041`) (#19023) Remove AlexWaygood as a flake8-pyi codeowner (#23347) [ty] Add comments to clarify the purpose of `NominalInstanceType::class_name` and `NominalInstanceType::class_module_name` (#23339) Add attestations for release artifacts and Docker images (#23111) [ty] Fix `assert_type` diagnostic messages (#23342) [ty] Force-update all insta snapshots (#23343) Add Q004 to the list of conflicting rules (#23340) [ty] Fix `invalid-match-pattern` false positives (#23338) [ty] new diagnostic called-match-pattern-must-be-a-type (#22939) [ty] Update flaky projects (#23337) [ty] Increase timeout for ecosystem report to 40 min (#23336) Bump ecosystem-analyzer pin (#23335) [ty] Replace `strsim` with CPython-based Levenshtein implementation (#23291) [ty] Add mdtest for staticmethod assigned in class body (#23330) [ty] fix inferring type variable from string literal argument (#23326) [ty] bytes literal is a sequence of integers (#23329) Update rand and getrandom (#23333) ...
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.
Summary
Any
typetype can only be inhabited by class objects; anytype | <dynamic type>union could materialize to a class object; and any<class object> & <dynamic type>intersection is a subtype of a class object. So using a value that inhabits any of these types as a class pattern should not cause us to emit theinvalid-match-patterndiagnostic.This PR fixes several false positives that showed up in the ecosystem report in #22939
Test Plan
mdtests added