graviti.utility.typing#

Graviti customized types.

Module Contents#

Classes#

NestedDict

Typehint for nested dict.

Functions#

check_type(name, value, expected_type)

Check the type of the argument.

Attributes#

graviti.utility.typing.PathLike[source]#
graviti.utility.typing.SortParam[source]#
class graviti.utility.typing.NestedDict[source]#

Bases: typing_extensions.Protocol[_K, _V]

Typehint for nested dict.

items(self)[source]#

Return (key, value) pairs of the dict.

Return type

AbstractSet[Tuple[_K, Union[NestedDict[_K, _V], _V]]]

setdefault(self, key, default)[source]#

Get the value of the key if exists, else set the value as default and return.

Parameters
  • key (_K) – The key.

  • default (Union[NestedDict[_K, _V], _V]) – The default value to set if the key does not exist.

Return type

Union[NestedDict[_K, _V], _V]

graviti.utility.typing.check_type(name, value, expected_type)[source]#

Check the type of the argument.

Parameters
  • name (str) – The name of the argument.

  • value (Any) – The value of the argument.

  • expected_type (Type[Any]) – The type of the argument.

Raises

TypeError – When the value is not of the type.

Return type

None