easydatamodel


Nameeasydatamodel JSON
Version 0.3.2 PyPI version JSON
download
home_pagehttps://github.com/jicruz96/easydatamodel
SummaryThe easiest way to create type-safe dataclasses in Python.
upload_time2024-07-19 22:07:27
maintainerNone
docs_urlNone
authorJ.I. Cruz
requires_python<4.0,>=3.11
licenseMIT
keywords data validation dataclasses validation models meta-programming
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# `easydatamodel` - The easiest way to create type-safe dataclasses in Python


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

```python
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.

```python
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`](https://docs.pydantic.dev/) 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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jicruz96/easydatamodel",
    "name": "easydatamodel",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.11",
    "maintainer_email": null,
    "keywords": "data validation, dataclasses, validation, models, meta-programming",
    "author": "J.I. Cruz",
    "author_email": "hello@jicruz.com",
    "download_url": "https://files.pythonhosted.org/packages/7d/5e/d0ac85f42971d79a11e7cab7e6826618a1c27a794d81bd7d408714927f38/easydatamodel-0.3.2.tar.gz",
    "platform": null,
    "description": "\n# `easydatamodel` - The easiest way to create type-safe dataclasses in Python\n\n\nJust annotate your fields and you're good to go.\n\n```python\nfrom easydatamodel import Model\n\nclass Person(Model):\n    name: str\n    age: int\n```\n\nNow you have a completely type-safe model that will validate your data for you, every time.\n\n```python\nPerson(name=\"John Doe\", age=1)  # \u2705 OK\nPerson(name=\"John Doe\", age=\"timeless\")  # \u274c InvalidModelError\n\n# easydatamodel also validates new value assignments\nperson = Person(name=\"John Doe\", age=1)\nperson.age = \"is but a number\" # \u274c raises a TypeError\n```\n## Install\n\n```\npip install easydatamodel\n```\n\n\n## Requirements\n* Python 3.11+\n\n## `easydatamodel` vs. `pydantic` and `dataclasses`\n\n| Feature                                | `easydatamodel` | `pydantic`     | `dataclasses` |\n| -------------------------------------- | --------------- | -------------- | ------------- |\n| **Validates data on instantiation**    | \u2705               | \u2705              | \u274c             |\n| **Validates data on assignment**       | \u2705               | Off by default | \u274c             |\n| **`ClassVar` validation**              | \u2705               | \u274c              | \u274c             |\n| **Automagic type coercion by default** | \u274c               | \u2705              | \u274c             |\n\n### Should you use `easydatamodel`?\n\n`easydatamodel` is perfect for simple, type-safe dataclasses with minimal effort and low overhead.\n\nHowever, you should consider using [`pydantic`](https://docs.pydantic.dev/) if you need more advanced features.\n\n\n### `easydatamodel` as a meta-programming resource\n\nGiven the size of the `easydatamodel` codebase, **`easydatamodel` is a fantastic resource for intermediate and advanced Python developers looking to learn how Python metaprogramming works.** \n\nThis codebase demonstrates how only a few files of Python code can create a powerful library with an ergonomic syntax.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "The easiest way to create type-safe dataclasses in Python.",
    "version": "0.3.2",
    "project_urls": {
        "Homepage": "https://github.com/jicruz96/easydatamodel",
        "Repository": "https://github.com/jicruz96/easydatamodel"
    },
    "split_keywords": [
        "data validation",
        " dataclasses",
        " validation",
        " models",
        " meta-programming"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0c3073313dc7f37f3fb80e5acf2d6202c0d9e31615f7eaeab88226dd4068a826",
                "md5": "00cf63aa9a06232677979c6dd09a1672",
                "sha256": "11f9d6ce4503aa2a182f569dc684a5eb575a893bc779a51f36432a855220fd26"
            },
            "downloads": -1,
            "filename": "easydatamodel-0.3.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "00cf63aa9a06232677979c6dd09a1672",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.11",
            "size": 13451,
            "upload_time": "2024-07-19T22:07:25",
            "upload_time_iso_8601": "2024-07-19T22:07:25.809042Z",
            "url": "https://files.pythonhosted.org/packages/0c/30/73313dc7f37f3fb80e5acf2d6202c0d9e31615f7eaeab88226dd4068a826/easydatamodel-0.3.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7d5ed0ac85f42971d79a11e7cab7e6826618a1c27a794d81bd7d408714927f38",
                "md5": "090d82e125bc65829c70318fa6030252",
                "sha256": "0f620c9ab39740f7e585db340978d2287ea116050cbeea44b5226c37afe7889f"
            },
            "downloads": -1,
            "filename": "easydatamodel-0.3.2.tar.gz",
            "has_sig": false,
            "md5_digest": "090d82e125bc65829c70318fa6030252",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.11",
            "size": 10736,
            "upload_time": "2024-07-19T22:07:27",
            "upload_time_iso_8601": "2024-07-19T22:07:27.219164Z",
            "url": "https://files.pythonhosted.org/packages/7d/5e/d0ac85f42971d79a11e7cab7e6826618a1c27a794d81bd7d408714927f38/easydatamodel-0.3.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-19 22:07:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jicruz96",
    "github_project": "easydatamodel",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "easydatamodel"
}
        
Elapsed time: 0.27571s