common.typing
StrAny
immutable, covariant entity
StrStr
immutable, covariant entity
StrStrStr
immutable, covariant entity
TFun
any function
TSecretValue
type: ignore
TSecretStrValue
type: ignore
TDataItem
A single data item as extracted from data source
TDataItems
A single data item or a list as extracted from the data source
TAnyDateTime
DateTime represented as pendulum/python object, ISO string or unix timestamp
ConfigValue
value of type None indicating argument that may be injected by config provider
SupportsVariant Objects
@runtime_checkable
class SupportsVariant(Protocol, Generic[TVariantBase])
Defines variant type protocol that should be recognized by normalizers
Variant types behave like TVariantBase type (ie. Decimal) but also implement the protocol below that is used to extract the variant value from it.
See Wei
type declaration which returns Decimal or str for values greater than supported by destination warehouse.
SupportsHumanize Objects
class SupportsHumanize(Protocol)
asdict
def asdict() -> DictStrAny
Represents object as dict with a schema loadable by dlt
asstr
def asstr(verbosity: int = 0) -> str
Represents object as human readable string
extract_inner_type
def extract_inner_type(hint: Type[Any],
preserve_new_types: bool = False) -> Type[Any]
Gets the inner type from Literal, Optional, Final and NewType
Arguments:
hint
Type[Any] - Type to extractpreserve_new_types
bool - Do not extract supertype of a NewType
Returns:
Type[Any]
- Inner type if hint was Literal, Optional or NewType, otherwise hint
get_generic_type_argument_from_instance
def get_generic_type_argument_from_instance(
instance: Any, sample_value: Optional[Any]) -> Type[Any]
Infers type argument of a Generic class from an instance
of that class using optional sample_value
of the argument type
Inference depends on the presence of orig_class attribute in instance, if not present - sample_Value will be used
Arguments:
instance
Any - instance of Generic classsample_value
Optional[Any] - instance of type of generic class, optional
Returns:
Type[Any]
- type argument or Any if not known
copy_sig
def copy_sig(
wrapper: Callable[TInputArgs, Any]
) -> Callable[[Callable[..., TReturnVal]], Callable[TInputArgs, TReturnVal]]
Copies docstring and signature from wrapper to func but keeps the func return value type