Metadata-Version: 2.1
Name: datta
Version: 0.1.0
Summary: Implementation of Slotted Data Classes compatible with Python 2.7 and 3.7+.
Home-page: https://github.com/brunonicko/datta
Author: Bruno Nicko
Author-email: brunonicko@gmail.com
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >= 2.7, != 3.0.*, != 3.1.*, != 3.2.*, != 3.3.*, != 3.4.*, != 3.5.*, != 3.6.*
Description-Content-Type: text/x-rst
License-File: LICENSE
Requires-Dist: basicco (<9,>=8.7)
Requires-Dist: estruttura (<2,>=1.1.2)
Requires-Dist: pyrsistent (<1,>=0)
Requires-Dist: six (<2,>=1)
Requires-Dist: tippo (<4,>=3.9)
Requires-Dist: enum34 ; python_version < "3.4"

Datta
=====

.. image:: https://github.com/brunonicko/datta/workflows/MyPy/badge.svg
   :target: https://github.com/brunonicko/datta/actions?query=workflow%3AMyPy

.. image:: https://github.com/brunonicko/datta/workflows/Lint/badge.svg
   :target: https://github.com/brunonicko/datta/actions?query=workflow%3ALint

.. image:: https://github.com/brunonicko/datta/workflows/Tests/badge.svg
   :target: https://github.com/brunonicko/datta/actions?query=workflow%3ATests

.. image:: https://readthedocs.org/projects/datta/badge/?version=stable
   :target: https://datta.readthedocs.io/en/stable/

.. image:: https://img.shields.io/github/license/brunonicko/datta?color=light-green
   :target: https://github.com/brunonicko/datta/blob/main/LICENSE

.. image:: https://static.pepy.tech/personalized-badge/datta?period=total&units=international_system&left_color=grey&right_color=brightgreen&left_text=Downloads
   :target: https://pepy.tech/project/datta

.. image:: https://img.shields.io/pypi/pyversions/datta?color=light-green&style=flat
   :target: https://pypi.org/project/datta/

Overview
--------
Immutable data structures based on `estruttura <https://github.com/brunonicko/estruttura>`_.

Examples
--------

.. code:: python

    >>> from datta import Data, attribute
    >>> class Point(Data):
    ...     x = attribute(types=int)
    ...     y = attribute(types=int)
    ...
    >>> point_a = Point(3, 4)
    >>> point_a
    Point(3, 4)
    >>> point_b = point_a.update(x=30, y=40)
    >>> point_b
    Point(30, 40)

.. code:: python

    >>> from datta import Data, attribute, list_attribute
    >>> from tippo import Literal
    >>> class Vehicle(Data):
    ...     kind = attribute(types=str)
    ...
    >>> class Garage(Data):
    ...     vehicles = list_attribute(types=Vehicle)
    ...     gate = attribute(default="automatic", types=str)  # type: Literal["automatic", "manual"]
    ...
    >>> garage = Garage([Vehicle("bicycle"), Vehicle("car")], gate="manual")
    >>> garage
    Garage([Vehicle('bicycle'), Vehicle('car')], gate='manual')
    >>> garage.serialize() == {"vehicles": [{"kind": "bicycle"}, {"kind": "car"}], "gate": "manual"}
    True
    >>> Garage.deserialize({"vehicles": [{"kind": "bicycle"}, {"kind": "car"}], "gate": "manual"}) == garage
    True

.. code:: python

    >>> from datta import list_cls
    >>> MyStrList = list_cls(converter=str, qualified_name="MyStrList")
    >>> my_str_list = MyStrList([1, 2.2, None, True])
    >>> my_str_list
    MyStrList(['1', '2.2', 'None', 'True'])
