Skip to main content

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:

  • All annotations are inspect._empty when there is no annotation.
  • sigparse.Parameter.default is inspect._empty when there is no default value.
  • sigparse.Parameter.kind is inspect._ParameterKind.
  • sigparse.ClassVar.default is inspect._empty when there is no default value to maintain consistency.

Annotated

typing.Annotated will always be evaluated with include_extras=True in python3.9.

Metadata

Release files for sigparse 3.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sigparse 3.0.0
File Size Uploaded
sigparse-3.0.0.tar.gz 5.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sigparse 3.0.0
File Interpreter ABI Platform
sigparse-3.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.5 kB

Release files / sigparse-3.0.0.tar.gz

Download URL sigparse-3.0.0.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
608d14fd5ead44d84482f2a1139803a0416157a0bac2fffa12382caac9566680
BLAKE2b-256 checksum
How to use checksums
1d6633bb71611ce82c5464ec4d741ac5ac8416a2b96e87f88934e06db2525fb4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.8.16 Linux/5.15.0-1031-azure

Release files / sigparse-3.0.0-py3-none-any.whl

Download URL sigparse-3.0.0-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
51926c7914e5386d43d9503036c93e698e5a32cb88fc8336d89187739f04ddee
BLAKE2b-256 checksum
How to use checksums
c16b96a46ebb118f19bb5f94e2e5553a3552ed97bd8501f592ff005ce0f3185d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.8.16 Linux/5.15.0-1031-azure

Release history Release notifications | RSS feed

This release

3.0.0 This release

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.4.0

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page