Welcome to correct’s documentation!
Note
If object is not listed in documentation it should be considered as implementation detail that can change and should not be relied upon.
- correct.predicates.is_subtype()[source]
Checks if annotation is a subtype of another.
>>> is_subtype(int, int) True >>> is_subtype(bool, int) # types are considered invariant by default False >>> from typing import TypeVar >>> CovariantInt = TypeVar('CovariantInt', bound=int, covariant=True) >>> is_subtype(bool, CovariantInt) True >>> is_subtype(int, bool) False >>> ContravariantBool = TypeVar('ContravariantBool', bound=bool, ... contravariant=True) >>> is_subtype(int, ContravariantBool) True