Skip to main content

Extended kit and tools for pydantic, to enjoy pydantic even more!

Project description

PydKit

Release Build status codecov Commit activity License

Extended kit and tools for pydantic, to enjoy pydantic even more!

Contribution

I'll work on this library in few months, i don't have free time right now, but feel free to contribute. I'll check and test the PRs myself!

Features

Use case of CSV read/write would be:

  1. Saving to a CSV file
from pydkit import csv
from pydantic import BaseModel

class User(BaseModel):
    id: int
    name: str

users = [
    User(id=1, name="Alice"),
    User(id=2, name="Abbas"),
]
csv.save("file.csv", users)
  1. Reading from a CSV file
from pydkit.csv import read, StrNone
from pydantic import BaseModel

class User(BaseModel):
    id: int
    name: str
    last_name: None | StrNone = None
    # StrNone helps you with reading from csv files!

users = csv.read("file.csv", User) # now user is list of User
  1. Type extensions -> Auto converter types
from pydkit.timezones import UTCTime

class User(BaseModel):
    created_at: UTCTime

now if you use this model, it'll convert timezones to UTC automatically in your FastAPI application or else, you can also write custom validation

from pydkit.timezones import UTCBiggerThanNow

class User(BaseModel):
    future_ts: UTCBiggerThanNow

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

pydkit-0.0.2.tar.gz (4.1 kB view hashes)

Uploaded Source

Built Distribution

pydkit-0.0.2-py3-none-any.whl (5.0 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