Basic type casting.
Project description
castfit
Basic type casting.
Changelog - Issues - Documentation
Why?
I'm writing more and more type-checked code, but I often get a bunch of strings I need to convert (e.g., from docopt
).
pydantic
feels heavy.type-docopt
uses a new syntax.bottle
seems like good inspiration for small, useful libraries.
Install
python -m pip install castfit
Example
from pathlib import Path
from castfit import castfit
class Cat:
name: str
age: int
weight: float
logo: Path
bob = castfit(Cat, dict(name="Bob", age="4", weight="3.2", logo="./bob.png"))
assert bob.name == "Bob"
assert bob.age == 4
assert bob.weight == 3.2
assert bob.logo == Path("./bob.png")
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
castfit-0.1.0.tar.gz
(8.4 kB
view details)
Built Distribution
File details
Details for the file castfit-0.1.0.tar.gz
.
File metadata
- Download URL: castfit-0.1.0.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 896d1398f25b0c5a85a847d60a3bd9ec949a69bfe008a713f66834930eb90f7f |
|
MD5 | a3c808d49c50cabb0467ef52fca68160 |
|
BLAKE2b-256 | 3b3e21718a4c72a4978ea371c41b64989d8bf1460e812f4fcf32150ffd096393 |
File details
Details for the file castfit-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: castfit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc3ecdc1acaf71538f3e686c0e811acd671bd985cf72f46701e52f7c205c4858 |
|
MD5 | 9c3139d43c1003bd92b0e100eb90a9dc |
|
BLAKE2b-256 | cb1693ce76d88ab3b0a126460c01cb1359ceac3cd21612fbdc87d35fab20a4ba |