Basic type casting.
Project description
castfit: basic type casting
Cuddles the Cat
"If it fits, I sits."
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).
pydanticfeels heavy.type-docoptuses a new syntax.bottleseems like good inspiration for small, useful libraries.
Install
python -m pip install castfit
Alternatively, you can just download the single file and name it castfit.py.
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
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.1.tar.gz
(9.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file castfit-0.1.1.tar.gz.
File metadata
- Download URL: castfit-0.1.1.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41f2c9152c95c2c42dc86e79007028f81c418c00d59ec1c0569596a4f1da0849
|
|
| MD5 |
e36be722adbe1e58fbb29abc6c933384
|
|
| BLAKE2b-256 |
978c4f7f87773ed59cf01121633adbd6ecb303ffff5a27985e84367521e096b6
|
File details
Details for the file castfit-0.1.1-py3-none-any.whl.
File metadata
- Download URL: castfit-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b47e859e8e0aae736e2e2973704d23603947770ea5a069d4d04bf84d2679ac1c
|
|
| MD5 |
b7e6dd0385e3f189f572ed9a57069cf9
|
|
| BLAKE2b-256 |
cccb581fc38683b5ed092cd91651983b3b52dfa2f6e754391e9d3428b4ab4db4
|