You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Existing type checkers (and the typing spec) allow calling an object of type type[C] (in red-knot, Type::SubclassOf(<Class C>)), with the result of the call being an object of type C (in red-knot, Type::Instance(<Class C>)).
This is not actually sound, because Liskov compatibility is not enforced on type constructor methods (__init__ and __new__) when subclassing, so you can't be sure that a constructor call that works for a class C will actually work for a subclass of C. But it's widely relied on, and we will have to support it.
I would like to have an opt-in diagnostic emitted whenever you call an object of type[C], so users who want to avoid this unsoundness have that option.
The text was updated successfully, but these errors were encountered:
On second thought, it may be best to hold off on this issue (or at least the new-diagnostic part of it) until after @AlexWaygood completes an in-progress refactor of CallOutcome, since this diagnostic would likely imply adding a new outcome variant to CallOutcome?
I can take it whenever @AlexWaygood is ready since I've triggered the issue in the first place. Not sure how you manage blocked issues, but feel free to assign this one to me and I'll monitor the comments
Description
Existing type checkers (and the typing spec) allow calling an object of type
type[C]
(in red-knot,Type::SubclassOf(<Class C>)
), with the result of the call being an object of typeC
(in red-knot,Type::Instance(<Class C>)
).This is not actually sound, because Liskov compatibility is not enforced on type constructor methods (
__init__
and__new__
) when subclassing, so you can't be sure that a constructor call that works for a classC
will actually work for a subclass ofC
. But it's widely relied on, and we will have to support it.I would like to have an opt-in diagnostic emitted whenever you call an object of
type[C]
, so users who want to avoid this unsoundness have that option.The text was updated successfully, but these errors were encountered: