Trite hacks for use with typing.
Latest release 20260525: Sortable and EQSortable Protocols which support lt and both eq and lt respectively.
Short summary:
EQSortable: A type whose instances can be sorted and also tested for equality i.e.is_optional: Check ifannotationis anOptional[type]. Returntypeif so,Noneotherwise.Sortable: A type whose instances can be sorted i.e.subtype: Construct aTypeVarfor subtypes of the typet.
Module contents:
-
class EQSortable(typing.Protocol): A type whose instances can be sorted and also tested for equality i.e. support the<and==operators. -
is_optional(annotation): Check ifannotationis anOptional[type]. Returntypeif so,Noneotherwise. -
class Sortable(typing.Protocol): A type whose instances can be sorted i.e. support the<operator. -
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 20260525: Sortable and EQSortable Protocols which support lt and both eq and lt respectively.
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 20260525
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-20260525.tar.gz | 2.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cs_typingutils-20260525-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 4.7 kB
Release files / cs_typingutils-20260525.tar.gz
| Download URL | cs_typingutils-20260525.tar.gz |
|---|---|
| Size | 2.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3ae520c9f26558fd2ef2a229fa794b3ef6732fc7389f23dea9e8868a2084a783
|
|
BLAKE2b-256 checksum How to use checksums |
d82f1766e9b372a08bfd5294648524aa6dfaa2b13b5739d144aee78e7c501f99
|
| 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-20260525-py2.py3-none-any.whl
| Download URL | cs_typingutils-20260525-py2.py3-none-any.whl |
|---|---|
| Size | 2.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
b046a91d38b9630333cb48f9f2bb7910f4232b0f3f62aadcd640672504371de5
|
|
BLAKE2b-256 checksum How to use checksums |
6469928454e78999d302d0cab5a473927c02a81721e2ada112fc71c20bb6e9bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.1
|