
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
.. _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 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 is hosted on ReadTheDocs: https://typeit.readthedocs.io/en/develop/
Run existing test suite with
.. code::
$ make test
See CHANGELOG <https://github.com/avanov/typeit/blob/master/CHANGELOG.rst>
_.
FAQs
typeit brings typed data into your project
We found that typeit demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.