Skip to main content

The easiest way to create type-safe dataclasses in Python.

Project description

easydatamodel - The easiest way to create type-safe dataclasses in Python

Just annotate your fields and you're good to go.

from easydatamodel import Model

class Person(Model):
    name: str
    age: int

Now you have a completely type-safe model that will validate your data for you, every time.

Person(name="John Doe", age=1)  # ✅ OK
Person(name="John Doe", age="timeless")  # ❌ InvalidModelError

# easydatamodel also validates new value assignments
person = Person(name="John Doe", age=1)
person.age = "is but a number" # ❌ raises a TypeError

Install

pip install easydatamodel

Requirements

  • Python 3.11+

easydatamodel vs. pydantic and dataclasses

Feature easydatamodel pydantic dataclasses
Validates data on instantiation
Validates data on assignment Off by default
ClassVar validation
Automagic type coercion by default

Should you use easydatamodel?

easydatamodel is perfect for simple, type-safe dataclasses with minimal effort and low overhead.

However, you should consider using pydantic if you need more advanced features.

easydatamodel as a meta-programming resource

Given the size of the easydatamodel codebase, easydatamodel is a fantastic resource for intermediate and advanced Python developers looking to learn how Python metaprogramming works.

This codebase demonstrates how only a few files of Python code can create a powerful library with an ergonomic syntax.

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

easydatamodel-0.3.2.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

easydatamodel-0.3.2-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file easydatamodel-0.3.2.tar.gz.

File metadata

  • Download URL: easydatamodel-0.3.2.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.1 Darwin/23.5.0

File hashes

Hashes for easydatamodel-0.3.2.tar.gz
Algorithm Hash digest
SHA256 0f620c9ab39740f7e585db340978d2287ea116050cbeea44b5226c37afe7889f
MD5 090d82e125bc65829c70318fa6030252
BLAKE2b-256 7d5ed0ac85f42971d79a11e7cab7e6826618a1c27a794d81bd7d408714927f38

See more details on using hashes here.

File details

Details for the file easydatamodel-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: easydatamodel-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.1 Darwin/23.5.0

File hashes

Hashes for easydatamodel-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 11f9d6ce4503aa2a182f569dc684a5eb575a893bc779a51f36432a855220fd26
MD5 00cf63aa9a06232677979c6dd09a1672
BLAKE2b-256 0c3073313dc7f37f3fb80e5acf2d6202c0d9e31615f7eaeab88226dd4068a826

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page