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

[red-knot] ClassLiteral(<T>) is not a disjoint type from Instance(<metaclass of T>) #14970

Merged
merged 2 commits into from
Dec 14, 2024

Conversation

AlexWaygood
Copy link
Member

Summary

A class is an instance of its metaclass, so ClassLiteral("ABC") is not disjoint from Instance("ABCMeta"). However, we erroneously consider the two types disjoint on the main branch. This PR fixes that.

This bug was uncovered by adding some more core types to the property tests that provide coverage for classes that have custom metaclasses. The additions to the property tests are included in this PR.

Test Plan

New unit tests and property tests added. Tested with:

  • cargo test -p red_knot_python_semantic
  • QUICKCHECK_TESTS=100000 cargo test -p red_knot_python_semantic -- --ignored types::property_tests::stable

The assignability property test fails on this branch, but that's a known issue that exists on main, due to #14899.

@AlexWaygood AlexWaygood added the red-knot Multi-file analysis & type inference label Dec 14, 2024
@AlexWaygood AlexWaygood added the bug Something isn't working label Dec 14, 2024
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Copy link
Contributor

@carljm carljm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@carljm carljm merged commit 4d64cdb into main Dec 14, 2024
21 checks passed
@carljm carljm deleted the alex/property-tests branch December 14, 2024 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working red-knot Multi-file analysis & type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants