Skip to content

Latest commit

 

History

History
76 lines (48 loc) · 3.36 KB

README.md

File metadata and controls

76 lines (48 loc) · 3.36 KB

Discord Playground Stable Version Downloads Documentation Checked with basedmypy Code style: black Linting: Ruff

Amon Gus. Amon Gus.

Based Static Typing for Python

Basedmypy is a Python type checker that is built on top of the work done by the mypy project. It resolves fundamental issues, limitations and compromises that exist within Mypy and Python's type system.

Based features include:

  • Typesafe by default (optional and dynamic typing still supported)
  • Baseline functionality
  • Support for Intersection types
  • Default return type of None instead of Any
  • Generic TypeVar bounds
  • Based type-guards
  • Infer parameter type from default value
  • Infer overload types
  • Bare literals
  • Tuple literal types

See the the docs for a comprehensive list.

BasedPyright

Also, take a look at BasedPyright, a based type checker and language server based on Pyright!

Usage

Basedmypy is installed as an alternative to, and in place of, the mypy installation:

mypy test.py

python -m mypy test.py

Why?

basedmypy was created to attempt to resolve two issues within Python and Mypy's typing ecosystem and to demonstrate new typing concepts:

  1. Mypy is lacking numerous pieces of functionality
  2. Pythons type system is full of deeply concerning compromises

You can find a comprehensive list of features in the docs.

Integrations

If you are using vscode, we recommend the mypy extension

If you are using IntelliJ IDEA/PyCharm, we recommend the basedtyping plugin

If you are using Pydantic, we recommend pydantic-basedtyping

Baseline

Basedmypy supports a feature called baseline. It allows you to adopt new strictness or features without the burden of refactoring and fixing every new error, just save all current errors to the baseline file and resolve them at what ever pace you want. Only new code will report new errors.

Read more and see examples in the docs