Skip to main content

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)

PEP604

By default PEP 604 (| for unions) is only enabled for sigparse.sigparse. To enable globally:

import sigparse
sigparse.global_PEP604()

Notes

Inspect

This module uses inspect behind the scenes. For that reason:

  • 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.

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

sigparse-2.0.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

sigparse-2.0.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file sigparse-2.0.0.tar.gz.

File metadata

  • Download URL: sigparse-2.0.0.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

Hashes for sigparse-2.0.0.tar.gz
Algorithm Hash digest
SHA256 b04e98204eda47712fe943061f7a2d3fdc55534e92b2661fbc64b4ff03b6e9b3
MD5 3b57049e1c5e8b5669436d274ff76b63
BLAKE2b-256 f15063b1ee0c6951ca0a5034924c4150dfe5e67d91dcd85d2bd1a9fa05d89460

See more details on using hashes here.

File details

Details for the file sigparse-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: sigparse-2.0.0-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

Hashes for sigparse-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6f9f5e86b86040790f920f7234722f631011cedc3e22fdc8afbc29a284e918a6
MD5 4fa3cc823b3bd81deaa87bbb22cadd68
BLAKE2b-256 31e3d2c7a1bc3f7683643cc31b86f3a733d5fe1ea39c95a26753db219c96634d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page