Hints
hints
¶
annotated_type = type(Annotated[int, 0])
module-attribute
¶
This is the type of an Annotated object.
PropertyType = type(_Class.property)
module-attribute
¶
The type of a property method.
isa(arg: Any, hint: TypeForm[_T]) -> TypeGuard[_T]
¶
Source code in xdsl/utils/hints.py
assert_isa(arg: Any, hint: TypeForm[_T]) -> TypeGuard[_T]
¶
Check if arg is of the type described by hint.
For now, only lists, dictionaries, unions,
and non-generic classes are supported for type hints.
Source code in xdsl/utils/hints.py
get_type_var_from_generic_class(cls: type[Any]) -> tuple[TypeVar, ...]
¶
Return the TypeVar used in the class Generic parent.
Source code in xdsl/utils/hints.py
get_type_var_mapping(cls: type[Any]) -> tuple[tuple[TypeVar, ...], dict[TypeVar, Any]]
¶
Given a Generic class, return the TypeVars used to specialize it, and the mapping from the generic class type variables to the specialized arguments for all type variables used in ancestor classes. Raises a ValueError if the specialized arguments for the same TypeVar are not consistent among superclasses.
Source code in xdsl/utils/hints.py
get_type_var_mapping_with_defaults(cls: type[Any]) -> dict[TypeVar, Any]
¶
Given a Generic class, returns the mapping from the generic class type variables to the specialized arguments for all type variables used in ancestor classes. Maps unspecialized type variables to their defaults, if they exist.
Source code in xdsl/utils/hints.py
type_repr(obj: Any) -> str
¶
Return the repr() of an object, special-casing types.