Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsonalias

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonalias

A microlibrary that defines a Json type alias for Python.

  • 0.1.2
  • PyPI
  • Socket score

Maintainers
1

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.

FAQs


Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc