Skip to main content

Basic type casting.

Project description

castfit

Basic type casting.

Build Status castfit on PyPI Supported Python versions

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).

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

MIT 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.0.tar.gz (8.4 kB view hashes)

Uploaded Source

Built Distribution

castfit-0.1.0-py3-none-any.whl (6.1 kB view hashes)

Uploaded Python 3

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