pub enum TypeInfo {
    Any,
    None,
    NoReturn,
    Callable(Option<Vec<TypeInfo>>, Box<TypeInfo>),
    Tuple(Option<Vec<TypeInfo>>),
    UnsizedTypedTuple(Box<TypeInfo>),
    Class {
        module: ModuleName,
        name: Cow<'static, str>,
        type_vars: Vec<TypeInfo>,
    },
}experimental-inspect only.Expand description
Designation of a Python type.
This enum is used to handle advanced types, such as types with generics.
Its Display implementation can be used to convert to the type hint notation (e.g. List[int]).
Variants§
Any
The type typing.Any, which represents any possible value (unknown type).
None
The type typing.None.
NoReturn
The type typing.NoReturn, which represents functions that never return (they can still panic / throw, similar to never in Rust).
Callable(Option<Vec<TypeInfo>>, Box<TypeInfo>)
The type typing.Callable.
The first argument represents the parameters of the callable:
- Someof a vector of types to represent the signature,
- Noneif the signature is unknown (allows any number of arguments with type- Any).
The second argument represents the return type.
Tuple(Option<Vec<TypeInfo>>)
The type typing.tuple.
The argument represents the contents of the tuple:
- Someof a vector of types to represent the accepted types,
- Someof an empty vector for the empty tuple,
- Noneif the number and type of accepted values is unknown.
If the number of accepted values is unknown, but their type is, use Self::UnsizedTypedTuple.
UnsizedTypedTuple(Box<TypeInfo>)
The type typing.Tuple.
Use this variant to represent a tuple of unknown size but of known types.
If the type is unknown, or if the number of elements is known, use Self::Tuple.
Class
A Python class.
Implementations§
Source§impl TypeInfo
 
impl TypeInfo
Sourcepub fn module_name(&self) -> Option<&str>
 
pub fn module_name(&self) -> Option<&str>
Returns the module in which a type is declared.
Returns None if the type is declared in the current module.
Source§impl TypeInfo
 
impl TypeInfo
Sourcepub fn optional_of(t: TypeInfo) -> TypeInfo
 
pub fn optional_of(t: TypeInfo) -> TypeInfo
The Python Optional type.
Sourcepub fn sequence_of(t: TypeInfo) -> TypeInfo
 
pub fn sequence_of(t: TypeInfo) -> TypeInfo
The Python Sequence type.
Sourcepub fn frozen_set_of(t: TypeInfo) -> TypeInfo
 
pub fn frozen_set_of(t: TypeInfo) -> TypeInfo
The Python FrozenSet type.
Sourcepub fn iterable_of(t: TypeInfo) -> TypeInfo
 
pub fn iterable_of(t: TypeInfo) -> TypeInfo
The Python Iterable type.
Sourcepub fn iterator_of(t: TypeInfo) -> TypeInfo
 
pub fn iterator_of(t: TypeInfo) -> TypeInfo
The Python Iterator type.
Sourcepub fn mapping_of(k: TypeInfo, v: TypeInfo) -> TypeInfo
 
pub fn mapping_of(k: TypeInfo, v: TypeInfo) -> TypeInfo
The Python Mapping type.
Trait Implementations§
impl StructuralPartialEq for TypeInfo
Auto Trait Implementations§
impl Freeze for TypeInfo
impl RefUnwindSafe for TypeInfo
impl Send for TypeInfo
impl Sync for TypeInfo
impl Unpin for TypeInfo
impl UnwindSafe for TypeInfo
Blanket Implementations§
Source§impl<T> AssertNotZeroSized for T
 
impl<T> AssertNotZeroSized for T
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
§impl<Q, K> Equivalent<K> for Q
 
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
 
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
 
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
 
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> SizedTypeProperties for T
 
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)] const IS_ZST: bool = _
 
#[doc(hidden)] const IS_ZST: bool = _
sized_type_properties)Source§#[doc(hidden)] const LAYOUT: Layout = _
 
#[doc(hidden)] const LAYOUT: Layout = _
sized_type_properties)Source§#[doc(hidden)] const MAX_SLICE_LEN: usize = _
 
#[doc(hidden)] const MAX_SLICE_LEN: usize = _
sized_type_properties)[Self]. Read more