Skip to content

Conformance suite: rewrite directives_version_platform.py to not assume that type checkers will ignore all errors in unreachable code#2202

Merged
carljm merged 2 commits intomainfrom
alex/sys-version-info-tests
Mar 5, 2026
Merged

Conformance suite: rewrite directives_version_platform.py to not assume that type checkers will ignore all errors in unreachable code#2202
carljm merged 2 commits intomainfrom
alex/sys-version-info-tests

Conversation

@AlexWaygood
Copy link
Member

The typing spec states:

Type checkers are expected to understand simple version and platform checks

ty does! However, it currently fails 100% of the assertions in conformance/tests/directives_version_platform.py, because it attempts to provide some type checking of code even if that code is in a region deemed to be unreachable. All the assertions in this file currently assume that a good way to test whether a type checker understands sys.version_info or sys.platform checks is to assert that they will emit no errors for obviously incorrect code in unreachable branches. But as far as I know, this is not described anywhere as a requirement for spec-conformant type checkers.

This PR rewrites the tests in this file so that they still assert that type checkers properly understand simple version and platform checks, but so that they no longer assume that type checkers will silence all errors in regions of code that they deem to be unreachable. With these changes, ty passes 100% of the assertions in this file. The conformance score of all other type checkers on this file is unchanged.

…sume that type checkers will ignore all errors in unreachable code
@AlexWaygood AlexWaygood added the topic: conformance tests Issues with the conformance test suite label Feb 28, 2026
Co-authored-by: Carl Meyer <carl@oddbird.net>
@carljm carljm merged commit 7f8f6bb into main Mar 5, 2026
6 checks passed
@carljm carljm deleted the alex/sys-version-info-tests branch March 5, 2026 18:00
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.

3 participants