mypy

Optional static typing for Python

https://github.com/python/mypy

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    20 of 785 committers (2.5%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.5%) to scientific vocabulary

Keywords

linter python typechecker types typing

Keywords from Contributors

closember unit-testing pydantic codeformatter formatter autopep8 gofmt yapf pre-commit-hook json-schema
Last synced: 6 months ago · JSON representation

Repository

Optional static typing for Python

Basic Info
  • Host: GitHub
  • Owner: python
  • License: other
  • Language: Python
  • Default Branch: master
  • Homepage: https://www.mypy-lang.org/
  • Size: 71.5 MB
Statistics
  • Stars: 19,736
  • Watchers: 240
  • Forks: 2,999
  • Open Issues: 2,985
  • Releases: 0
Topics
linter python typechecker types typing
Created about 13 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog Contributing License

README.md

mypy logo

Mypy: Static Typing for Python

Stable Version Downloads Build Status Documentation Status Chat at https://gitter.im/python/typing Checked with mypy Code style: black Linting: Ruff

Got a question?

We are always happy to answer questions! Here are some good places to ask them:

If you're just getting started, the documentation and type hints cheat sheet can also help answer questions.

If you think you've found a bug:

To report a bug or request an enhancement:

To discuss a new type system feature:

What is mypy?

Mypy is a static type checker for Python.

Type checkers help ensure that you're using variables and functions in your code correctly. With mypy, add type hints (PEP 484) to your Python programs, and mypy will warn you when you use those types incorrectly.

Python is a dynamic language, so usually you'll only see errors in your code when you attempt to run it. Mypy is a static checker, so it finds bugs in your programs without even running them!

Here is a small example to whet your appetite:

python number = input("What is your favourite number?") print("It is", number + 1) # error: Unsupported operand types for + ("str" and "int")

Adding type hints for mypy does not interfere with the way your program would otherwise run. Think of type hints as similar to comments! You can always use the Python interpreter to run your code, even if mypy reports errors.

Mypy is designed with gradual typing in mind. This means you can add type hints to your code base slowly and that you can always fall back to dynamic typing when static typing is not convenient.

Mypy has a powerful and easy-to-use type system, supporting features such as type inference, generics, callable types, tuple types, union types, structural subtyping and more. Using mypy will make your programs easier to understand, debug, and maintain.

See the documentation for more examples and information.

In particular, see:

Quick start

Mypy can be installed using pip:

bash python3 -m pip install -U mypy

If you want to run the latest version of the code, you can install from the repo directly:

bash python3 -m pip install -U git+https://github.com/python/mypy.git

Now you can type-check the statically typed parts of a program like this:

bash mypy PROGRAM

You can always use the Python interpreter to run your statically typed programs, even if mypy reports type errors:

bash python3 PROGRAM

If you are working with large code bases, you can run mypy in daemon mode, that will give much faster (often sub-second) incremental updates:

bash dmypy run -- PROGRAM

You can also try mypy in an online playground (developed by Yusuke Miyazaki).

Integrations

Mypy can be integrated into popular IDEs:

Web site and documentation

Additional information is available at the web site:

https://www.mypy-lang.org/

Jump straight to the documentation:

https://mypy.readthedocs.io/

Follow along our changelog at:

https://mypy-lang.blogspot.com/

Contributing

Help in testing, development, documentation and other tasks is highly appreciated and useful to the project. There are tasks for contributors of all experience levels.

To get started with developing mypy, see CONTRIBUTING.md.

Mypyc and compiled version of mypy

Mypyc uses Python type hints to compile Python modules to faster C extensions. Mypy is itself compiled using mypyc: this makes mypy approximately 4 times faster than if interpreted!

To install an interpreted mypy instead, use:

bash python3 -m pip install --no-binary mypy -U mypy

To use a compiled version of a development version of mypy, directly install a binary from https://github.com/mypyc/mypy_mypyc-wheels/releases/latest.

To contribute to the mypyc project, check out the issue tracker at https://github.com/mypyc/mypyc

Owner

  • Name: Python
  • Login: python
  • Kind: organization

Repositories related to the Python Programming language

Committers

Last synced: 6 months ago

All Time
  • Total Commits: 12,300
  • Total Committers: 785
  • Avg Commits per committer: 15.669
  • Development Distribution Score (DDS): 0.606
Past Year
  • Commits: 811
  • Committers: 105
  • Avg Commits per committer: 7.724
  • Development Distribution Score (DDS): 0.824
Top Committers
Name Email Commits
Jukka Lehtosalo j****o@i****i 4,841
Michael J. Sullivan s****y@m****t 856
Ivan Levkivskyi l****i@g****m 793
Shantanu 1****a 607
Guido van Rossum g****o@p****g 309
Guido van Rossum g****o@d****m 293
Nikita Sobolev m****l@s****e 293
Marc Mueller 3****p 217
Sander Kersten s****n@g****m 198
Alex Waygood A****d@G****m 166
Michael Lee m****a@g****m 155
David Fisher d****1@g****m 153
Igor Vuk p****a@g****m 146
Ethan Smith e****n@e****e 115
Elazar Gershuni e****g@g****m 114
jhance j****e 101
Michael Pokorny p****k@d****m 100
Xuanda Yang t****e@g****m 99
Jelle Zijlstra j****a@g****m 92
97littleleaf11 9****1 80
Stanislav Terliakov 5****v 79
Eric Price e****e@m****u 68
Ilya Priven i****v@g****m 67
Svyatoslav Ilinskiy i****v@g****m 58
Reid Barton r****n@g****m 55
Greg Price g****e@d****m 54
Brian Schubert b****t@g****m 42
github-actions[bot] 4****] 41
Ali Hamdan a****v@g****m 40
Jared Pochtar j****d@d****m 38
and 755 more...

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 3,138
  • Total pull requests: 3,002
  • Average time to close issues: over 1 year
  • Average time to close pull requests: about 1 month
  • Total issue authors: 1,605
  • Total pull request authors: 348
  • Average comments per issue: 2.98
  • Average comments per pull request: 2.64
  • Merged pull requests: 2,040
  • Bot issues: 0
  • Bot pull requests: 79
Past Year
  • Issues: 862
  • Pull requests: 1,798
  • Average time to close issues: 9 days
  • Average time to close pull requests: 6 days
  • Issue authors: 491
  • Pull request authors: 168
  • Average comments per issue: 1.18
  • Average comments per pull request: 2.04
  • Merged pull requests: 1,220
  • Bot issues: 0
  • Bot pull requests: 41
Top Authors
Issue Authors
  • KotlinIsland (113)
  • JukkaL (103)
  • DetachHead (66)
  • hauntsaninja (46)
  • randolf-scholz (35)
  • sobolevn (33)
  • ilevkivskyi (30)
  • bzoracler (29)
  • Dreamsorcerer (29)
  • finite-state-machine (26)
  • JelleZijlstra (24)
  • bersbersbers (24)
  • asottile-sentry (21)
  • A5rocks (20)
  • NeilGirdhar (20)
Pull Request Authors
  • JukkaL (350)
  • cdce8p (330)
  • ilevkivskyi (296)
  • hauntsaninja (289)
  • sterliakov (173)
  • sobolevn (105)
  • brianschubert (93)
  • github-actions[bot] (62)
  • hamdanal (54)
  • svalentin (52)
  • tyralla (49)
  • A5rocks (47)
  • wyattscarpenter (42)
  • AlexWaygood (40)
  • JelleZijlstra (32)
Top Labels
Issue Labels
bug (2,150) feature (506) crash (228) priority-1-normal (166) topic-type-narrowing (114) false-positive (106) topic-type-variables (96) needs discussion (69) topic-typed-dict (67) topic-paramspec (66) priority-2-low (66) documentation (63) topic-usability (62) topic-overloads (55) priority-0-high (53) topic-reachability (50) topic-match-statement (50) topic-join-v-union (47) topic-descriptors (47) topic-configuration (45) topic-daemon (44) topic-runtime-semantics (44) topic-pep-646 (42) topic-error-reporting (42) topic-enum (41) topic-stubgen (38) good-first-issue (34) meta (34) topic-type-context (33) topic-protocols (32)
Pull Request Labels
upnext (115) topic-mypyc (88) topic-stubgen (33) documentation (21) topic-pep-696 (17) topic-tests (16) topic-pep-702 (13) topic-typed-dict (8) topic-stubtest (8) dependencies (8) pending (7) topic-type-narrowing (6) deferred (5) topic-type-ignore (4) topic-daemon (4) topic-strict-optional (4) topic-dataclass-transform (4) topic-paramspec (4) topic-configuration (3) topic-literal-types (3) topic-pep-585 (3) topic-overloads (3) topic-dataclasses (3) topic-match-statement (3) python (2) topic-pep-695 (2) topic-async (2) bug (2) topic-join-v-union (2) topic-enum (2)

Packages

  • Total packages: 12
  • Total downloads:
    • pypi 65,006,985 last-month
  • Total docker downloads: 2,085,803,744
  • Total dependent packages: 6,269
    (may contain duplicates)
  • Total dependent repositories: 53,705
    (may contain duplicates)
  • Total versions: 422
  • Total maintainers: 16
pypi.org: mypy

Optional static typing for Python

  • Versions: 129
  • Dependent Packages: 6,214
  • Dependent Repositories: 52,771
  • Downloads: 64,903,280 Last month
  • Docker Downloads: 2,085,803,744
Rankings
Dependent packages count: 0.0%
Dependent repos count: 0.0%
Docker downloads count: 0.0%
Downloads: 0.0%
Average: 0.1%
Stargazers count: 0.3%
Forks count: 0.4%
Last synced: 6 months ago
conda-forge.org: mypy

Add type annotations to your Python programs, and use mypy to type check them. Mypy is essentially a Python linter on steroids, and it can catch many programming errors by analyzing your program, without actually having to run it. Mypy has a powerful type system with features such as type inference, gradual typing, generics and union types.

  • Versions: 44
  • Dependent Packages: 25
  • Dependent Repositories: 364
Rankings
Dependent repos count: 1.5%
Stargazers count: 2.1%
Average: 2.1%
Forks count: 2.2%
Dependent packages count: 2.7%
Last synced: 6 months ago
conda-forge.org: mypy_extensions

The 'mypy_extensions' module defines experimental extensions to the standard 'typing' module that are supported by the mypy typechecker.

  • Versions: 4
  • Dependent Packages: 22
  • Dependent Repositories: 205
Rankings
Stargazers count: 2.1%
Forks count: 2.2%
Dependent repos count: 2.4%
Average: 2.4%
Dependent packages count: 3.0%
Last synced: 6 months ago
proxy.golang.org: github.com/python/mypy
  • Versions: 40
  • Dependent Packages: 0
  • Dependent Repositories: 1
Rankings
Forks count: 0.1%
Stargazers count: 0.5%
Average: 3.7%
Dependent repos count: 4.7%
Dependent packages count: 9.6%
Last synced: 6 months ago
anaconda.org: mypy

Add type annotations to your Python programs, and use mypy to type check them. Mypy is essentially a Python linter on steroids, and it can catch many programming errors by analyzing your program, withoutactually having to run it. Mypy has a powerful type system with features such as type inference, gradual typing, generics and union types.

  • Versions: 31
  • Dependent Packages: 6
  • Dependent Repositories: 364
Rankings
Stargazers count: 5.9%
Forks count: 6.1%
Dependent repos count: 8.8%
Average: 9.0%
Dependent packages count: 15.1%
Last synced: 6 months ago
conda-forge.org: mypyc

The compiled language is a strict, gradually typed Python variant. It restricts the use of some dynamic Python features to gain performance, but it's mostly compatible with standard Python. Mypyc uses mypy to perform type checking and type inference. Most type system features in the stdlib typing module are supported. Compiled modules can import arbitrary Python modules and third-party libraries. You can compile anything from a single performance-critical module to your entire codebase. You can run the modules you compile also as normal, interpreted Python modules. Existing code with type annotations is often 1.5x to 5x faster when compiled. Code tuned for mypyc can be 5x to 10x faster. Mypyc currently aims to speed up non-numeric code, such as server applications. Mypyc is also used to compile itself (and mypy).

  • Versions: 2
  • Dependent Packages: 1
  • Dependent Repositories: 0
Rankings
Stargazers count: 2.0%
Forks count: 2.1%
Average: 16.7%
Dependent packages count: 28.8%
Dependent repos count: 34.0%
Last synced: 6 months ago
github actions: python/mypy

Optional Static Typing for Python.

  • Versions: 104
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 0.0%
Average: 17.2%
Dependent repos count: 34.3%
Last synced: 6 months ago
pypi.org: crgeo

Contains basic functionality for facilitating research on graph neural networks for autonomous driving and provides an interface between CommonRoad and Pytorch Geometric.

  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 130 Last month
Rankings
Dependent packages count: 6.6%
Average: 18.6%
Dependent repos count: 30.6%
Maintainers (2)
Last synced: about 1 year ago
pypi.org: zxgraphs

A vectorised implementation of ZX graphs.

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 1 Last month
Rankings
Dependent packages count: 6.6%
Average: 26.7%
Forks count: 30.5%
Dependent repos count: 30.6%
Stargazers count: 39.1%
Maintainers (1)
Last synced: 6 months ago
pypi.org: bismuth-mypy

Optional static typing for Python

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 20,503 Last month
Rankings
Dependent packages count: 10.3%
Average: 34.3%
Dependent repos count: 58.2%
Maintainers (1)
Last synced: 6 months ago
pypi.org: mypy-dev

Optional static typing for Python

  • Versions: 53
  • Dependent Packages: 1
  • Dependent Repositories: 0
  • Downloads: 83,071 Last month
Rankings
Dependent packages count: 9.8%
Average: 37.3%
Dependent repos count: 64.7%
Maintainers (1)
Last synced: 6 months ago
anaconda.org: mypyc

Add type annotations to your Python programs, and use mypy to type check them. Mypy is essentially a Python linter on steroids, and it can catch many programming errors by analyzing your program, withoutactually having to run it. Mypy has a powerful type system with features such as type inference, gradual typing, generics and union types.

  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 50.5%
Average: 54.9%
Dependent repos count: 59.4%
Last synced: 6 months ago

Dependencies

build-requirements.txt pypi
  • types-typed-ast >=1.5.0,<1.6.0
docs/requirements-docs.txt pypi
  • furo >=2022.3.4
  • sphinx >=4.2.0,<5.0.0
.github/workflows/docs.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/build_wheels.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/mypy_primer.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • actions/upload-artifact v3 composite
.github/workflows/mypy_primer_comment.yml actions
  • actions/github-script v6 composite
  • kanga333/comment-hider c12bb20b48aeb8fc098e35967de8d4f8018fffdf composite
.github/workflows/sync_typeshed.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/test.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/test_stubgenc.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
action.yml actions
misc/docker/Dockerfile docker
  • ubuntu latest build
mypy-requirements.txt pypi
  • mypy_extensions >=1.0.0
  • tomli >=1.1.0
  • typing_extensions >=4.1.0
mypyc/lib-rt/setup.py pypi
pyproject.toml pypi
setup.py pypi
  • mypy_extensions *
  • tomli >=1.1.0
  • typing_extensions >=4.1.0
test-data/packages/typedpkg/pyproject.toml pypi
test-data/packages/typedpkg-stubs/pyproject.toml pypi
test-data/packages/typedpkg_ns_a/pyproject.toml pypi
test-data/packages/typedpkg_ns_b/pyproject.toml pypi
test-data/packages/typedpkg_ns_b-stubs/pyproject.toml pypi
test-data/pybind11_mypy_demo/pyproject.toml pypi
test-data/pybind11_mypy_demo/setup.py pypi
test-requirements.in pypi
  • attrs >=18.0 test
  • black ==23.9.1 test
  • filelock >=3.3.0 test
  • lxml >=4.9.1,<4.9.3 test
  • pre-commit * test
  • pre-commit-hooks ==4.5.0 test
  • psutil >=4.0 test
  • pytest >=7.4.0 test
  • pytest-cov >=2.10.0 test
  • pytest-xdist >=1.34.0 test
  • ruff ==0.1.0 test
  • setuptools >=65.5.1 test
  • tomli >=1.1.0 test
test-requirements.txt pypi
  • attrs ==23.1.0 test
  • black ==23.9.1 test
  • cfgv ==3.4.0 test
  • click ==8.1.7 test
  • coverage ==7.3.2 test
  • distlib ==0.3.7 test
  • execnet ==2.0.2 test
  • filelock ==3.12.4 test
  • identify ==2.5.30 test
  • iniconfig ==2.0.0 test
  • lxml ==4.9.2 test
  • mypy-extensions ==1.0.0 test
  • nodeenv ==1.8.0 test
  • packaging ==23.2 test
  • pathspec ==0.11.2 test
  • platformdirs ==3.11.0 test
  • pluggy ==1.3.0 test
  • pre-commit ==3.5.0 test
  • pre-commit-hooks ==4.5.0 test
  • psutil ==5.9.6 test
  • pytest ==7.4.2 test
  • pytest-cov ==4.1.0 test
  • pytest-xdist ==3.3.1 test
  • pyyaml ==6.0.1 test
  • ruamel-yaml ==0.17.40 test
  • ruamel-yaml-clib ==0.2.8 test
  • ruff ==0.1.0 test
  • setuptools ==68.2.2 test
  • tomli ==2.0.1 test
  • types-psutil ==5.9.5.17 test
  • types-setuptools ==68.2.0.0 test
  • typing-extensions ==4.8.0 test
  • virtualenv ==20.24.5 test