typeit


Nametypeit JSON
Version 3.11.1.3 PyPI version JSON
download
home_pagehttps://github.com/avanov/typeit
Summarytypeit brings typed data into your project
upload_time2023-10-27 19:32:17
maintainer
docs_urlNone
authorMaxim Avanov
requires_python
license
keywords utils typing json yaml serialization deserialization structured-data
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. _badges:

.. image:: https://github.com/avanov/typeit/workflows/CI/badge.svg?branch=develop
    :target: https://github.com/avanov/typeit/actions?query=branch%3Adevelop

.. image:: https://coveralls.io/repos/github/avanov/typeit/badge.svg?branch=develop
    :target: https://coveralls.io/github/avanov/typeit?branch=develop

.. image:: https://requires.io/github/avanov/typeit/requirements.svg?branch=master
    :target: https://requires.io/github/avanov/typeit/requirements/?branch=master
    :alt: Requirements Status

.. image:: https://readthedocs.org/projects/typeit/badge/?version=latest
    :target: http://typeit.readthedocs.org/en/latest/
    :alt: Documentation Status

.. image:: http://img.shields.io/pypi/v/typeit.svg
    :target: https://pypi.python.org/pypi/typeit
    :alt: Latest PyPI Release


Typeit
------

**typeit** infers Python types from a sample JSON/YAML data, and provides you with the tools
for serialising and parsing it. It also provides you with smart constructors for arbitrarily nested data structures.
The library works superb on Python 3.7 and above.

Start using it by generating types for your JSON payloads:

.. code-block:: bash

    $ echo '{"first-name": "Hello", "initial": null, "last_name": "World"}' | typeit gen


The snipped above produces output similar to this:

.. code-block:: python

    from typing import Any, NamedTuple, Optional, Sequence
    from typeit import TypeConstructor


    class Main(NamedTuple):
        first_name: str
        initial: Optional[Any]
        last_name: str


    overrides = {
        Main.first_name: 'first-name',
    }


    mk_main, serialize_main = TypeConstructor & overrides ^ Main

Use these functions to construct and serialize your payloads:

.. code-block:: python

    payload = {"first-name": "Hello", "initial": None, "last_name": "World"}

    data = mk_main(payload)
    assert isinstance(data, Main)
    assert serialize_main(data) == payload


Documentation
-------------

Documentation is hosted on ReadTheDocs: https://typeit.readthedocs.io/en/develop/


Test framework
--------------

Run existing test suite with

.. code::

   $ make test


Changelog
---------

See `CHANGELOG <https://github.com/avanov/typeit/blob/master/CHANGELOG.rst>`_.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/avanov/typeit",
    "name": "typeit",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "utils typing json yaml serialization deserialization structured-data",
    "author": "Maxim Avanov",
    "author_email": "maxim.avanov@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/4f/c2/4453e98dd624feaa2f19aedb907701acc7024692f2dcf83df125bd5b7ba1/typeit-3.11.1.3.tar.gz",
    "platform": null,
    "description": ".. _badges:\n\n.. image:: https://github.com/avanov/typeit/workflows/CI/badge.svg?branch=develop\n    :target: https://github.com/avanov/typeit/actions?query=branch%3Adevelop\n\n.. image:: https://coveralls.io/repos/github/avanov/typeit/badge.svg?branch=develop\n    :target: https://coveralls.io/github/avanov/typeit?branch=develop\n\n.. image:: https://requires.io/github/avanov/typeit/requirements.svg?branch=master\n    :target: https://requires.io/github/avanov/typeit/requirements/?branch=master\n    :alt: Requirements Status\n\n.. image:: https://readthedocs.org/projects/typeit/badge/?version=latest\n    :target: http://typeit.readthedocs.org/en/latest/\n    :alt: Documentation Status\n\n.. image:: http://img.shields.io/pypi/v/typeit.svg\n    :target: https://pypi.python.org/pypi/typeit\n    :alt: Latest PyPI Release\n\n\nTypeit\n------\n\n**typeit** infers Python types from a sample JSON/YAML data, and provides you with the tools\nfor serialising and parsing it. It also provides you with smart constructors for arbitrarily nested data structures.\nThe library works superb on Python 3.7 and above.\n\nStart using it by generating types for your JSON payloads:\n\n.. code-block:: bash\n\n    $ echo '{\"first-name\": \"Hello\", \"initial\": null, \"last_name\": \"World\"}' | typeit gen\n\n\nThe snipped above produces output similar to this:\n\n.. code-block:: python\n\n    from typing import Any, NamedTuple, Optional, Sequence\n    from typeit import TypeConstructor\n\n\n    class Main(NamedTuple):\n        first_name: str\n        initial: Optional[Any]\n        last_name: str\n\n\n    overrides = {\n        Main.first_name: 'first-name',\n    }\n\n\n    mk_main, serialize_main = TypeConstructor & overrides ^ Main\n\nUse these functions to construct and serialize your payloads:\n\n.. code-block:: python\n\n    payload = {\"first-name\": \"Hello\", \"initial\": None, \"last_name\": \"World\"}\n\n    data = mk_main(payload)\n    assert isinstance(data, Main)\n    assert serialize_main(data) == payload\n\n\nDocumentation\n-------------\n\nDocumentation is hosted on ReadTheDocs: https://typeit.readthedocs.io/en/develop/\n\n\nTest framework\n--------------\n\nRun existing test suite with\n\n.. code::\n\n   $ make test\n\n\nChangelog\n---------\n\nSee `CHANGELOG <https://github.com/avanov/typeit/blob/master/CHANGELOG.rst>`_.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "typeit brings typed data into your project",
    "version": "3.11.1.3",
    "project_urls": {
        "Homepage": "https://github.com/avanov/typeit"
    },
    "split_keywords": [
        "utils",
        "typing",
        "json",
        "yaml",
        "serialization",
        "deserialization",
        "structured-data"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5eb917236686e661428cc1a3a71b54b38cf338b261d892d93641dc1b2c37d3c1",
                "md5": "a09f81609a0f12ee27a1fc5f3ae0e8c4",
                "sha256": "71df66c6d840f966ca25b2dbf643826d228b5ecb727de6ea174148daba71d45c"
            },
            "downloads": -1,
            "filename": "typeit-3.11.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a09f81609a0f12ee27a1fc5f3ae0e8c4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 35400,
            "upload_time": "2023-10-27T19:32:15",
            "upload_time_iso_8601": "2023-10-27T19:32:15.906732Z",
            "url": "https://files.pythonhosted.org/packages/5e/b9/17236686e661428cc1a3a71b54b38cf338b261d892d93641dc1b2c37d3c1/typeit-3.11.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4fc24453e98dd624feaa2f19aedb907701acc7024692f2dcf83df125bd5b7ba1",
                "md5": "95ef8463871c41baa36721732ab56d92",
                "sha256": "585bdb5d7b13a82ff3d842538b960e4b1f445d0c9c90863a2aec942d85600549"
            },
            "downloads": -1,
            "filename": "typeit-3.11.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "95ef8463871c41baa36721732ab56d92",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 30646,
            "upload_time": "2023-10-27T19:32:17",
            "upload_time_iso_8601": "2023-10-27T19:32:17.574354Z",
            "url": "https://files.pythonhosted.org/packages/4f/c2/4453e98dd624feaa2f19aedb907701acc7024692f2dcf83df125bd5b7ba1/typeit-3.11.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-27 19:32:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "avanov",
    "github_project": "typeit",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "typeit"
}
        
Elapsed time: 0.13905s