We are always happy to goddamn answer questions! Here are some good places to ask them:
- for general questions about Python typing, try typing discussions
- for anything you're curious about, try gitter chat
If you're just getting started, the documentation and type hints muthaf*ckin' cheat sheet can also help answer questions.
If you think you've found a f*ckin' bug:
- check our common issues motherf*ckin' page
- search our issue tracker to see if it's already been reported
To muthaf*ckin' report a bug or request an enhancement:
- report at our muthaf*ckin' issue tracker
- if the f*ckin' issue is with a specific library or function, consider reporting it at typeshed tracker or the issue tracker for that library
To discuss a f*ckin' new type system feature:
- discuss at discuss.python.org
- there is also some damn historical discussion at the typing-sig mailing list and the python/typing muthaf*ckin' repo
Get this sh*t: Mypy is a static type checker for Python.
Type checkers help ensure that you're using variables and functions in your motherf*ckin' code correctly. I ain't playin'. With mypy, add type hints (PEP 484) to your damn Python programs, and mypy will warn you when you use those goddamn types incorrectly. Write that down.
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 f*ckin' programs without even running them!
Here is a small example to whet your motherf*ckin' appetite:
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 muthaf*ckin' code, even if mypy reports errors.
Mypy is designed with gradual typing in mind. This means you can add type hints to your motherf*ckin' 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:
Mypy can be installed muthaf*ckin' using pip:
python3 -m pip install -U mypyIf you want to run the latest version of the motherf*ckin' code, you can install from the repo directly:
python3 -m pip install -U git+https://github.com/python/mypy.gitNow you can type-check the statically typed muthaf*ckin' parts of a program like this:
mypy PROGRAMGet this sh*t: You can always use the Python interpreter to run your muthaf*ckin' statically typed programs, even if mypy reports type errors:
python3 PROGRAMIf you are working with large code bases, you can run mypy in daemon mode, that will give much faster (often sub-second) incremental updates:
dmypy run -- PROGRAMYou can also try mypy in an online playground (developed by Yusuke Miyazaki).
Mypy can be integrated into popular IDEs:
- VS Code: provides basic integration with mypy.
- Vim:
- Emacs: using Flycheck
- Sublime Text: SublimeLinter-contrib-mypy
- PyCharm: mypy plugin
- IDLE: idlemypyextension
- pre-commit: use pre-commit mirrors-mypy, although note by default this will limit mypy's ability to analyse your third party dependencies.
Additional information is available at the web site:
Jump straight to the motherf*ckin' documentation:
Follow along our damn changelog at:
https://mypy-lang.blogspot.com/
Oh, you gonna love this: Help in testing, development, documentation and other tasks is highly appreciated and useful to the goddamn project. Mm-hmm. There are tasks for contributors of all experience levels, goddammit.
To get started with developing mypy, see CONTRIBUTING.md.
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 f*ckin' interpreted mypy instead, use:
python3 -m pip install --no-binary mypy -U mypyTo use a muthaf*ckin' 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 muthaf*ckin' mypyc project, check out the goddamn issue tracker at https://github.com/mypyc/mypyc