Trite hacks for use with typing.
Latest release 20250503: is_optional: bugfix: Optional[T] has a get_args of (T,), not (T,None).
Short summary:
is_optional: Check ifannotationis anOptional[type]. Returntypeif so,Noneotherwise.subtype: Construct aTypeVarfor subtypes of the typet.
Module contents:
-
is_optional(annotation): Check ifannotationis anOptional[type]. Returntypeif so,Noneotherwise. -
subtype(t, name=None): Construct aTypeVarfor subtypes of the typet.Parameters:
t: the type which bounds theTypeVarname: optional name for theTypeVar, defaultt.__name__ + 'SubType'
Release Log
Release 20250503: is_optional: bugfix: Optional[T] has a get_args of (T,), not (T,None).
Release 20250428: New is_optional(annotation) function to recognise Optional[type] annotations, returning type if true, None otherwise.
Release 20230331: Initial release.
Release files for cs-typingutils 20250503
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cs_typingutils-20250503.tar.gz | 1.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cs_typingutils-20250503-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 4.1 kB
Release files / cs_typingutils-20250503.tar.gz
| Download URL | cs_typingutils-20250503.tar.gz |
|---|---|
| Size | 1.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b9c402f83bb467a654b5e83c70e74bd356ca332aca2f30b413b45e48f31c4bc8
|
|
BLAKE2b-256 checksum How to use checksums |
597a29271ce15cdaa2974a63092a399846de0b99063f23297ef83b1be98252a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.1
|
Release files / cs_typingutils-20250503-py2.py3-none-any.whl
| Download URL | cs_typingutils-20250503-py2.py3-none-any.whl |
|---|---|
| Size | 2.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
26962aa0aed9dd5899ec83b2be788840c5eb1fe0ac72118dfdcc879b4f8d88f0
|
|
BLAKE2b-256 checksum How to use checksums |
cc77fbc5d4893758d2fc53324a420b0a9d53cc2913472113e225a9ec8e2b8515
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.1
|