Skip to main content

singledispatch with support for type/class arguments

Project description

singledispatch-with-type-arg-support

Standalone "preview" of https://github.com/python/cpython/pull/100624

Based off cpython commit c4c5790120beabed83ce5855f18d209ab8324434

Installation

Requires a sufficiently recent Python 3.12 version (some tests fail with earlier 3.12 versions, although the main functionality might still work - do your own testing).

pip3 install singledispatch-with-type-arg-support

Example

See example.py:

from singledispatch_with_type_arg_support import singledispatch

@singledispatch
def describe(x) -> str:
  raise TypeError(f"no description for {repr(x)}")

@describe.register
def _(x: type[int]) -> str:
  return "the integer type"

print(describe(int))  # should print: the integer type

License

Same as CPython (as 99% of it is copied from there), see LICENSE file.

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

File details

Details for the file singledispatch_with_type_arg_support-0.1.3.tar.gz.

File metadata

File hashes

Hashes for singledispatch_with_type_arg_support-0.1.3.tar.gz
Algorithm Hash digest
SHA256 906b7454cb907453d1668c283a1bfeaa2d6120feb0a353222a53f4d52d705627
MD5 2b7bfe8abb4ade8589c0fc2c542b2a91
BLAKE2b-256 d895692075c684cebee03832bd171745e71e159c7177799f840cb4850ea14f17

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