Backports python3.10 typing features into python 3.7 and newer.
Project description
sigparse
Backports python3.10 typing features into python 3.7, 3.8, and 3.9.
Example
import sigparse
def func(param_a: list[str], param_b: str | int, param_c: tuple[int | None]):
...
# This returns the same result in python 3.7, 3.8, 3.9, and 3.10!
sigparse.sigparse(func)
Sigparse also supports classes.
import sigparse
class MyClass:
a: list[str]
b: str | int
c: tuple[int | None]
sigparse.classparse(MyClass)
PEP 604
By default PEP 604 (| for unions) is only enabled for sigparse.sigparse
and sigparse.classparse
.
The code for PEP 604 was written by @Endercheif.
To enable globally:
import sigparse
sigparse.global_PEP604()
Notes
Inspect
This module uses inspect behind the scenes. For that reason:
sigparse.Parameter.default
isinspect._empty
when there is no default value.sigparse.Parameter.kind
isinspect._ParameterKind
.sigparse.ClassVar.default
isinspect._empty
when there is no default value to maintain consistency.
Annotated
typing.Annotated
will always be evaluated with include_extras=True
in python3.9.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sigparse-2.0.1.tar.gz
(4.9 kB
view details)
Built Distribution
File details
Details for the file sigparse-2.0.1.tar.gz
.
File metadata
- Download URL: sigparse-2.0.1.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.8.14 Linux/5.15.0-1020-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45106a72e29642c6d78085245bf89918dc5531967581b9d1c106474b93326bf5 |
|
MD5 | bf261ea9d5cf7333de59109dc70a2260 |
|
BLAKE2b-256 | c3476816d5fca4014118eb69be11dd25c758a50cde630cf0fb8bb9a91030a49a |
File details
Details for the file sigparse-2.0.1-py3-none-any.whl
.
File metadata
- Download URL: sigparse-2.0.1-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.8.14 Linux/5.15.0-1020-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b24fefb65c17511f2c50516522d88191994d2868d4c93fa0df677b361fe1206f |
|
MD5 | f677112f58014944385cd00acd926f85 |
|
BLAKE2b-256 | d7f7a03cf92b0f4f660a7968ea4112e0b7b11d99a40a01cc9225bcd9269d7fb0 |