Skip to main content

jsonalias

A microlibrary that defines a Json type alias for Python.

This README is longer than the library

Seriously, this is all the code:

from typing import Dict, List, Union

Json = Union[Dict[str, "Json"], List["Json"], str, int, float, bool, None]

If we only supported Python >= 3.10, it would fit on one line:

Json = dict[str, 'Json'] | list['Json'] | str | int | float | bool | None

Then why make a library out of it?

I want to use this type alias in multiple projects and it's just about long enough to be annoying.

This alias should probably get added to the Python typing module. If it does and I haven't put a big notice on this README, please open a PR.

Example

from jsonalias import Json

d: Json = {"foo": ["bar", {"x": "y"}]}

It's not working please help???

Make sure you're using mypy >= 0.981 and running with the --enable-recursive-aliases flag.

Special Thanks

GitHub user wbolster for this comment notifying us that mypy could now do JSON.

Release files for jsonalias 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jsonalias 0.1.2
File Size Uploaded
jsonalias-0.1.2.tar.gz 2.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jsonalias 0.1.2
File Interpreter ABI Platform
jsonalias-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 5.4 kB

Release files / jsonalias-0.1.2.tar.gz

Download URL jsonalias-0.1.2.tar.gz
Size 2.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e397874a4a13b45c500565703dc71bd42011efde0570246de7a92d284610ac4c
BLAKE2b-256 checksum
How to use checksums
2adf59ca5f3319dc6d432d79303242f4c9fc50412de36d61de0f697d757faaba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.14 CPython/3.9.13 Linux/5.15.57-2-MANJARO

Release files / jsonalias-0.1.2-py3-none-any.whl

Download URL jsonalias-0.1.2-py3-none-any.whl
Size 2.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0dece9b199f6aa9a6a2dcfa81d233f5673a9227b66ab16425c39eebf4b45bb94
BLAKE2b-256 checksum
How to use checksums
cdb7490d6c62692be5f458c133196586ae4be6dd03604b246a7360654f1237f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.14 CPython/3.9.13 Linux/5.15.57-2-MANJARO

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page