A package for extended built-in types
Project description
typing-ex
A python package for extended typing (python 3.8+)
Installation
pip install typing-ex
Notice
Even with all tests passed, unexpected bugs might occur on edge cases
Frozen frozen.py
FrozenList: ImmutablelistFrozenDict: Immutabledictfrozen_copy: Create frozen copy of supported types (Sequence,Set,Mapping)
TypeInfo type_info.py Documentation
TypeInfo: provide type information and run-time type checkingTypeInfo.get(t): alias ofTypeInfo[t]TypeInfo.of(value): return aTypeInfoobject that represents the type ofvalueTypeInfo.check_union(t1, t2): check if union type t1 fulfill union type t2TypeInfo[t].type: typeTypeInfo[t].origin: unsubscripted typeTypeInfo[t].args: type argumentsTypeInfo[t].name: name of type (including arguments)TypeInfo[t].check_value(value): check if value matches the type in type infoTypeInfo[t].is_*: check if type is _
TypedDefaultDict typed_defaultdict.py Documentation
-
TypedDefaultDict: combining features ofTypedDictanddefaultdictwith type checking in__init__,__setitem__,__setattr__andupdateTypedDefaultDict.schema: the schema dictionary:MappingProxyType[str, NamedTuple[default: Any, type:TypeInfo]]TypedDefaultDict.on_get_unknown_property: called on getting unknown propertyTypedDefaultDict.on_set_unknown_property: called on setting unknown propertyTypedDefaultDict.set: set a property to a value without property check and type check@factorymethod(property_name: str): defines a factory method for property
-
Attributes without type annotation or starting with underscore "_" will be treated as class variables
-
Good for writing schema as a class for
JSON/YAML/XML/etc. data which provides both static and runtime type checking. Or you can use it as aclass, but without the need to write__init__
EnumEx enum_ex.py Documentation
EnumExis aEnumlike class that support enum aliasing (keeping same value but different name).-
EnumEx.__iter__: a generator of all non-alias enum instances. -
EnumEx.names: a tuple of all enum names. -
EnumEx.values: a tuple of all enum values. -
EnumEx.enums: a tuple of all enum instances. -
EnumEx.value_type: returns__value_type__if defined, int otherwise. -
EnumEx.X.value: value of enum X -
EnumEx.X.name: name of enum X (i.e. X) -
EnumEx.X_ALIAS.orig_name: original name of enum X_ALIAS (i.e. X) -
EnumEx.X_ALIAS.origin: origin enum of X_ALIAS (i.e. EnumEx.X)
-
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file typing_ex-0.1.33.tar.gz.
File metadata
- Download URL: typing_ex-0.1.33.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.12.3 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49bb89dce451bd63413f0a6f7b835de227bec6f25c7b7732b170eba7f4fcc5a2
|
|
| MD5 |
2cc4aeef33697a7e956d977e8320ad11
|
|
| BLAKE2b-256 |
239260105c7379338237798401a9968ffecca58ba065fccadf282cd854ccd40a
|
File details
Details for the file typing_ex-0.1.33-py3-none-any.whl.
File metadata
- Download URL: typing_ex-0.1.33-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.12.3 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
413177f0d3237a8c88c6bdd99402926bc85c1180266e4e8e95bd896d0673e722
|
|
| MD5 |
fa615c6f973586040ca9815b09ec682a
|
|
| BLAKE2b-256 |
c7d65138666fb0ea754df4d54bd1af929902b16c77aefdbffeaa4198817d89fa
|