basedpyright
basedpyright copied to clipboard
Invent a better `type`
Something that represents type realm types, not instances of builtins.type. The same as TypeForm, but with a different name.
Issues with type:
- Doesn't support
TypeForms - Constructor signatures are unchecked
- Requires special-casing (
type[type]) - The stubs don't mention the type parameter
-
typedoesn't accept abstract types
in the mean time i want to add a rule to ban type[T] syntax, because it's extremely unsafe
What about just banning __call__ on types?
Good idea. Then once we have intersections, we can just make a type alias that lets you specify its constructor parameters:
type Type[T, P] = type[T] & Callable[P, T]
- https://github.com/KotlinIsland/basedmypy/issues/628
- https://github.com/python/mypy/issues/1831