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
- Download URL: singledispatch_with_type_arg_support-0.1.3.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0a3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 906b7454cb907453d1668c283a1bfeaa2d6120feb0a353222a53f4d52d705627 |
|
MD5 | 2b7bfe8abb4ade8589c0fc2c542b2a91 |
|
BLAKE2b-256 | d895692075c684cebee03832bd171745e71e159c7177799f840cb4850ea14f17 |