{"id":21121507,"url":"https://github.com/jsonschema-typed/jsonschema-typed","last_synced_at":"2025-07-08T21:32:49.216Z","repository":{"id":57438220,"uuid":"183490681","full_name":"jsonschema-typed/jsonschema-typed","owner":"jsonschema-typed","description":"Use JSON Schema for type checking in Python","archived":false,"fork":false,"pushed_at":"2024-03-13T06:30:41.000Z","size":139,"stargazers_count":40,"open_issues_count":6,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-22T14:03:17.248Z","etag":null,"topics":["experimental","json","json-schema","mypy","static-analysis","typing"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsonschema-typed.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-25T18:40:33.000Z","updated_at":"2025-06-17T13:28:40.000Z","dependencies_parsed_at":"2024-08-23T22:19:09.311Z","dependency_job_id":"0aec480f-5ce9-4667-afda-983f8f6b814d","html_url":"https://github.com/jsonschema-typed/jsonschema-typed","commit_stats":null,"previous_names":["jsonschema-typed/jsonschema-typed","erickpeirson/jsonschema-typed"],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/jsonschema-typed/jsonschema-typed","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsonschema-typed%2Fjsonschema-typed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsonschema-typed%2Fjsonschema-typed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsonschema-typed%2Fjsonschema-typed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsonschema-typed%2Fjsonschema-typed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsonschema-typed","download_url":"https://codeload.github.com/jsonschema-typed/jsonschema-typed/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsonschema-typed%2Fjsonschema-typed/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264352898,"owners_count":23594989,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["experimental","json","json-schema","mypy","static-analysis","typing"],"created_at":"2024-11-20T03:50:59.001Z","updated_at":"2025-07-08T21:32:46.913Z","avatar_url":"https://github.com/jsonschema-typed.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![PyPI version](https://img.shields.io/pypi/v/jsonschema-typed.svg?logo=pypi\u0026logoColor=FFE873)](https://pypi.org/project/jsonschema-typed/)\n[![Python version](https://img.shields.io/pypi/pyversions/jsonschema-typed)](https://pypi.org/project/jsonschema-typed/)\n[![PyPI downloads](https://img.shields.io/pypi/dm/jsonschema-typed)](https://pypistats.org/packages/jsonschema-typed)\n[![License](https://img.shields.io/pypi/l/jsonschema-typed)](LICENSE)\n[![Code style: Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n# JSON Schema-powered type annotations\n\nThis package provides a way to automatically produce type annotations based\non [`jsonschema`-schemas](https://json-schema.org).\n\nNot all concepts covered by `jsonschema` are expressible within Python typing annotations. However, most things\nwill work like you'd expect. Most types are translated trivially\n(`integer`, `number`, `string`, `array`, `boolean` and `null`).\nThe interesting type is `object`, which is translated into a [``TypedDict``](https://www.python.org/dev/peps/pep-0589/).\n\n**Warning:** This is based on the [mypy plugin system](https://mypy.readthedocs.io/en/latest/extending_mypy.html), which\nis stated to have no backwards compatibility guarantee. New versions of mypy might not be supported immediately.\n\n## Example\n\nA JSON schema:\n\n```json\n{\n    \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n    \"$id\": \"http://foo.qwerty/some/schema#\",\n    \"title\": \"Foo Schema\",\n    \"type\": \"object\",\n    \"properties\": {\n        \"title\": {\n            \"type\": \"string\"\n        },\n        \"awesome\": {\n            \"type\": \"number\"\n        }\n    },\n    \"required\": [\"title\"]\n}\n```\n\nA TypedDict:\n\n```python\n\nfrom typing import TYPE_CHECKING\nfrom jsonschema_typed import JSONSchema\n\ndata: JSONSchema[\"path/to/schema.json\"] = {\"title\": \"baz\"}\n\nif TYPE_CHECKING:\n    reveal_type(data)  # Revealed type is 'TypedDict('FooSchema', {'title': builtins.str,\n                       #                                           'awesome'?: Union[builtins.int, builtins.float]})'\ndata[\"description\"] = \"there is no description\"  # TypedDict \"FooSchema\" has no key 'description'\ndata[\"awesome\"] = 42\ndata[\"awesome\"] = None  # Argument 2 has incompatible type \"None\"; expected \"Union[int, float]\"\n```\n\nYou can also get types of parts of a schema, as well as types of elements in arrays. Take a look at the\n[test cases](tests/cases) for more examples of usage.\n\n## Installation\n\n```bash\npip install jsonschema-typed\n```\n\nYou also need to enable the plugin(s) in your `mypy.ini` configuration file:\n\n```toml\n# mypy.ini\n[mypy]\nplugins = jsonschema_typed.plugin, jsonschema_typed.optional_typed_dict\n\n# Due to a quirk of how these type hints are generated, mypy's caching breaks.\n# Disabling caching might be required.\ncache_dir = /dev/null\n```\n\n## Requirements\n\nThe above installations resolves the dependencies, which consist of `mypy` and `jsonschema` (naturally).\nTesting has been done with versions:\n\n- mypy==0.761\n- jsonschema==3.2.0\n\nProbably some older versions will also work. Report an [issue](https://github.com/jsonschema-typed/jsonschema-typed/issues)\nif you need other versions.\n\n## Limitations\n\n- `additionalProperties` doesn't really have an equivalent in TypedDict.\n- The ``default`` keyword is not supported; but see: https://github.com/python/mypy/issues/6131.\n- Self-references (e.g. ``\"#\"``) can't really work properly until nested\n  forward-references are supported; see: https://github.com/python/mypy/issues/731.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsonschema-typed%2Fjsonschema-typed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsonschema-typed%2Fjsonschema-typed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsonschema-typed%2Fjsonschema-typed/lists"}