Skip to content

conformance: Fix questionable assert_type() with known class#2226

Merged
carljm merged 2 commits intopython:mainfrom
JelleZijlstra:barassert
Mar 25, 2026
Merged

conformance: Fix questionable assert_type() with known class#2226
carljm merged 2 commits intopython:mainfrom
JelleZijlstra:barassert

Conversation

@JelleZijlstra
Copy link
Member

The previous test asserted that type checkers should consider a direct
reference to the class to be equivalent to a type[] usage. But it is
entirely reasonable for type checkers to recognize the direct class
reference as an instance of a more precise singleton type, as ty does.
(Pycroscope also kind of does this but I'm still working on adjusting its
behavior.)

I replaced this test with assertions about the assignability of the
direct class reference to a few type[] variants.

The previous test asserted that type checkers should consider a direct
reference to the class to be equivalent to a type[] usage. But it is
entirely reasonable for type checkers to recognize the direct class
reference as an instance of a more precise singleton type, as ty does.
(Pycroscope also kind of does this but I'm still working on adjusting its
behavior.)

I replaced this test with assertions about the assignability of the
direct class reference to a few type[] variants.
@srittau srittau added the topic: conformance tests Issues with the conformance test suite label Mar 25, 2026
@carljm carljm merged commit 755292c into python:main Mar 25, 2026
5 checks passed
@JelleZijlstra JelleZijlstra deleted the barassert branch March 25, 2026 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic: conformance tests Issues with the conformance test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants