typing-derive
derive types from other types to make it easier to type code!
Installation
pip install typing-derive
usage
add as a mypy plugin
[mypy]
plugins = typing_derive.plugin
typing_derive.impl.typeddict_from_func
create a usable TypedDict from some callable. useful if you need to
dynamically build up **kwargs to call a function
from typing_derive.impl import typeddict_from_func
def f(x: int, y: str) -> None: ...
TD = typeddict_from_func('TD', f)
x: TD = {
'x': 1,
'y': 'hello hello',
}
f(**x)
typing_derive.impl.typeof
create a type alias for the type of a function / variable.
one use might be to pass functions of matching signatures as objects
def f(x: int, y: str) -> None: ...
F = typeof('F', f)
def g(func: F) -> None:
func(x=1, y='two')
def h(x: int, y: str) -> None: ...
def j(x: str, y: str) -> None: ...
def k(x1: int, y: str) -> None: ...
g(f) # ok
g(h) # ok
g(j) # error: `x` is `str` not `int`
g(k) # error: `x1` mismatches `x`
it also just works on normal variables too -- though I haven't come up with a use for this yet
x = 5
X = typeof('X', x) # effectively `type X = int`
y: X = 6 # ok
z: X = 'no' # not ok!
Metadata
Release files for typing-derive 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| typing_derive-1.2.0.tar.gz | 4.4 kB | Without provenance | Details for typing_derive-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| typing_derive-1.2.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for typing_derive-1.2.0-py2.py3-none-any.whl |
Total release size: 9.4 kB
Release files / typing_derive-1.2.0.tar.gz
| Download URL | typing_derive-1.2.0.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a1a752561e436e9b8c59df9b29b02911a2705b825e7137371b0e5f36b3954fc6
|
|
BLAKE2b-256 checksum How to use checksums |
067f47c7d462780020d79a082b0aa2b7fa6709c31d780bc19708b2e2dbccc81a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Release files / typing_derive-1.2.0-py2.py3-none-any.whl
| Download URL | typing_derive-1.2.0-py2.py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
ff02cff476410ffdecbd86358ab1b046be721825217bb1aa73df8b1e141c0351
|
|
BLAKE2b-256 checksum How to use checksums |
fc10c905fd82674e8feaffb9f4a88e340fe199033d4b7c8e102825b791620be2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Security for typing-derive 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.