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 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.
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 classCwill 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.