Skip to main content

Fits JSON values into Python type-anotated objects

Project description


Read the Docs Build Status LGTM Grade

Typing annotations make Python awesome, however it's complicated to keep your data annotated when it comes from external sources like APIs. The goal of Typefit is to help you map that external data into type-annotated native Python objects.

from typefit import api
from typing import NamedTuple, Text

class Item(NamedTuple):
    id: int
    title: Text

class HackerNews(api.SyncClient):
    BASE_URL = ""

    def get_item(self, item_id: int) -> Item:

story = HackerNews().get_item(42)
# An alternative to VC: "Selling In"

This is the full example of a Hacker News API client. Its functionality is limited but in 14 lines counting white space you can build a type-safe client for Hacker News. You'll find a full example attached if you're interested.


Documentation is there


This library is provided under the terms of the WTFPL.

If you find it useful, you can have a look at the contributors page to know who helped.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for typefit, version 0.3.0
Filename, size File type Python version Upload date Hashes
Filename, size typefit-0.3.0-py3-none-any.whl (23.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size typefit-0.3.0.tar.gz (20.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page