Getting started
|
Interna |
jugo Pasando |
Type hints cheat sheet
|
Interna |
jugo Pasando |
Using mypy with an existing codebase
|
Interna |
jugo Pasando |
Built-in types
|
Interna |
jugo Pasando |
Type inference and type annotations
|
Interna |
jugo Pasando |
Kinds of types
|
Interna |
jugo Pasando |
Class basics
|
Interna |
jugo Pasando |
Annotation issues at runtime
|
Interna |
jugo Pasando |
Protocols and structural subtyping
|
Interna |
jugo Pasando |
Dynamically typed code
|
Interna |
jugo Pasando |
Type narrowing
|
Interna |
jugo Pasando |
Duck type compatibility
|
Interna |
jugo Pasando |
Stub files
|
Interna |
jugo Pasando |
Generics
|
Interna |
jugo Pasando |
More types
|
Interna |
jugo Pasando |
Literal types and Enums
|
Interna |
jugo Pasando |
TypedDict
|
Interna |
jugo Pasando |
Final names, methods and classes
|
Interna |
jugo Pasando |
Metaclasses
|
Interna |
jugo Pasando |
Running mypy and managing imports
|
Interna |
jugo Pasando |
The mypy command line
|
Interna |
jugo Pasando |
The mypy configuration file
|
Interna |
jugo Pasando |
Inline configuration
|
Interna |
jugo Pasando |
Mypy daemon (mypy server)
|
Interna |
jugo Pasando |
Using installed packages
|
Interna |
jugo Pasando |
Extending and integrating mypy
|
Interna |
jugo Pasando |
Automatic stub generation (stubgen)
|
Interna |
jugo Pasando |
Automatic stub testing (stubtest)
|
Interna |
jugo Pasando |
Common issues and solutions
|
Interna |
jugo Pasando |
Supported Python features
|
Interna |
jugo Pasando |
Error codes
|
Interna |
jugo Pasando |
Error codes enabled by default
|
Interna |
jugo Pasando |
Error codes for optional checks
|
Interna |
jugo Pasando |
Additional features
|
Interna |
jugo Pasando |
Frequently Asked Questions
|
Interna |
jugo Pasando |
GitHub
|
Externa |
jugo Pasando |
Website
|
Externa |
jugo Pasando |
latest
|
Interna |
jugo Pasando |
stable
|
Interna |
jugo Pasando |
pdf
|
Interna |
jugo Pasando |
html
|
Interna |
jugo Pasando |
epub
|
Interna |
jugo Pasando |
Project Home
|
Interna |
jugo Pasando |
Builds
|
Interna |
jugo Pasando |
¶
|
Interna |
jugo Pasando |
¶
|
Interna |
jugo Pasando |
Installing and running mypy
|
Interna |
jugo Pasando |
Dynamic vs static typing
|
Interna |
jugo Pasando |
Strict mode and configuration
|
Interna |
jugo Pasando |
More complex types
|
Interna |
jugo Pasando |
Local type inference
|
Interna |
jugo Pasando |
Types from libraries
|
Interna |
jugo Pasando |
Next steps
|
Interna |
jugo Pasando |
Variables
|
Interna |
jugo Pasando |
Useful built-in types
|
Interna |
jugo Pasando |
Functions
|
Interna |
jugo Pasando |
Classes
|
Interna |
jugo Pasando |
When you’re puzzled or when things are complicated
|
Interna |
jugo Pasando |
Standard “duck types”
|
Interna |
jugo Pasando |
Forward references
|
Interna |
jugo Pasando |
Decorators
|
Interna |
jugo Pasando |
Coroutines and asyncio
|
Interna |
jugo Pasando |
Start small
|
Interna |
jugo Pasando |
Run mypy consistently and prevent regressions
|
Interna |
jugo Pasando |
Ignoring errors from certain modules
|
Interna |
jugo Pasando |
Fixing errors related to imports
|
Interna |
jugo Pasando |
Prioritise annotating widely imported modules
|
Interna |
jugo Pasando |
Write annotations as you go
|
Interna |
jugo Pasando |
Automate annotation of legacy code
|
Interna |
jugo Pasando |
Introduce stricter options
|
Interna |
jugo Pasando |
Speed up mypy runs
|
Interna |
jugo Pasando |
Simple types
|
Interna |
jugo Pasando |
Any type
|
Interna |
jugo Pasando |
Generic types
|
Interna |
jugo Pasando |
Type inference
|
Interna |
jugo Pasando |
Explicit types for variables
|
Interna |
jugo Pasando |
Explicit types for collections
|
Interna |
jugo Pasando |
Compatibility of container types
|
Interna |
jugo Pasando |
Context in type inference
|
Interna |
jugo Pasando |
Silencing type errors
|
Interna |
jugo Pasando |
Class types
|
Interna |
jugo Pasando |
The Any type
|
Interna |
jugo Pasando |
Tuple types
|
Interna |
jugo Pasando |
Callable types (and lambdas)
|
Interna |
jugo Pasando |
Union types
|
Interna |
jugo Pasando |
Optional types and the None type
|
Interna |
jugo Pasando |
Type aliases
|
Interna |
jugo Pasando |
Named tuples
|
Interna |
jugo Pasando |
The type of class objects
|
Interna |
jugo Pasando |
Generators
|
Interna |
jugo Pasando |
Instance and class attributes
|
Interna |
jugo Pasando |
Annotating __init__ methods
|
Interna |
jugo Pasando |
Class attribute annotations
|
Interna |
jugo Pasando |
Overriding statically typed methods
|
Interna |
jugo Pasando |
Abstract base classes and multiple inheritance
|
Interna |
jugo Pasando |
Slots
|
Interna |
jugo Pasando |
String literal types and type comments
|
Interna |
jugo Pasando |
Future annotations import (PEP 563)
|
Interna |
jugo Pasando |
typing.TYPE_CHECKING
|
Interna |
jugo Pasando |
Class name forward references
|
Interna |
jugo Pasando |
Import cycles
|
Interna |
jugo Pasando |
Using classes that are generic in stubs but not at runtime
|
Interna |
jugo Pasando |
Using types defined in stubs but not at runtime
|
Interna |
jugo Pasando |
Using generic builtins
|
Interna |
jugo Pasando |
Using X | Y syntax for Unions
|
Interna |
jugo Pasando |
Using new additions to the typing module
|
Interna |
jugo Pasando |
Predefined protocols
|
Interna |
jugo Pasando |
Simple user-defined protocols
|
Interna |
jugo Pasando |
Defining subprotocols and subclassing protocols
|
Interna |
jugo Pasando |
Invariance of protocol attributes
|
Interna |
jugo Pasando |
Recursive protocols
|
Interna |
jugo Pasando |
Using isinstance() with protocols
|
Interna |
jugo Pasando |
Callback protocols
|
Interna |
jugo Pasando |
Predefined protocol reference
|
Interna |
jugo Pasando |
Operations on Any values
|
Interna |
jugo Pasando |
Any vs. object
|
Interna |
jugo Pasando |
Type narrowing expressions
|
Interna |
jugo Pasando |
Casts
|
Interna |
jugo Pasando |
User-Defined Type Guards
|
Interna |
jugo Pasando |
Limitations
|
Interna |
jugo Pasando |
Creating a stub
|
Interna |
jugo Pasando |
Stub file syntax
|
Interna |
jugo Pasando |
Using stub file syntax at runtime
|
Interna |
jugo Pasando |
Defining generic classes
|
Interna |
jugo Pasando |
Defining subclasses of generic classes
|
Interna |
jugo Pasando |
Generic functions
|
Interna |
jugo Pasando |
Generic methods and generic self
|
Interna |
jugo Pasando |
Automatic self types using typing.Self
|
Interna |
jugo Pasando |
Variance of generic types
|
Interna |
jugo Pasando |
Type variables with upper bounds
|
Interna |
jugo Pasando |
Type variables with value restriction
|
Interna |
jugo Pasando |
Declaring decorators
|
Interna |
jugo Pasando |
Generic protocols
|
Interna |
jugo Pasando |
Generic type aliases
|
Interna |
jugo Pasando |
Generic class internals
|
Interna |
jugo Pasando |
The NoReturn type
|
Interna |
jugo Pasando |
NewTypes
|
Interna |
jugo Pasando |
Function overloading
|
Interna |
jugo Pasando |
Advanced uses of self-types
|
Interna |
jugo Pasando |
Typing async/await
|
Interna |
jugo Pasando |
Literal types
|
Interna |
jugo Pasando |
Enums
|
Interna |
jugo Pasando |
Totality
|
Interna |
jugo Pasando |
Supported operations
|
Interna |
jugo Pasando |
Class-based syntax
|
Interna |
jugo Pasando |
Mixing required and non-required items
|
Interna |
jugo Pasando |
Unions of TypedDicts
|
Interna |
jugo Pasando |
Final names
|
Interna |
jugo Pasando |
Final methods
|
Interna |
jugo Pasando |
Final classes
|
Interna |
jugo Pasando |
Defining a metaclass
|
Interna |
jugo Pasando |
Metaclass usage example
|
Interna |
jugo Pasando |
Gotchas and limitations of metaclass support
|
Interna |
jugo Pasando |
Specifying code to be checked
|
Interna |
jugo Pasando |
Reading a list of files from a file
|
Interna |
jugo Pasando |
Mapping file paths to modules
|
Interna |
jugo Pasando |
How mypy handles imports
|
Interna |
jugo Pasando |
Missing imports
|
Interna |
jugo Pasando |
How imports are found
|
Interna |
jugo Pasando |
Following imports
|
Interna |
jugo Pasando |
Specifying what to type check
|
Interna |
jugo Pasando |
Optional arguments
|
Interna |
jugo Pasando |
Config file
|
Interna |
jugo Pasando |
Import discovery
|
Interna |
jugo Pasando |
Platform configuration
|
Interna |
jugo Pasando |
Disallow dynamic typing
|
Interna |
jugo Pasando |
Untyped definitions and calls
|
Interna |
jugo Pasando |
None and Optional handling
|
Interna |
jugo Pasando |
Configuring warnings
|
Interna |
jugo Pasando |
Miscellaneous strictness flags
|
Interna |
jugo Pasando |
Configuring error messages
|
Interna |
jugo Pasando |
Incremental mode
|
Interna |
jugo Pasando |
Advanced options
|
Interna |
jugo Pasando |
Report generation
|
Interna |
jugo Pasando |
Enabling incomplete/experimental features
|
Interna |
jugo Pasando |
Miscellaneous
|
Interna |
jugo Pasando |
Config file format
|
Interna |
jugo Pasando |
Per-module and global options
|
Interna |
jugo Pasando |
Inverting option values
|
Interna |
jugo Pasando |
Import discovery
|
Interna |
jugo Pasando |
Platform configuration
|
Interna |
jugo Pasando |
Disallow dynamic typing
|
Interna |
jugo Pasando |
Untyped definitions and calls
|
Interna |
jugo Pasando |
None and Optional handling
|
Interna |
jugo Pasando |
Configuring warnings
|
Interna |
jugo Pasando |
Suppressing errors
|
Interna |
jugo Pasando |
Miscellaneous strictness flags
|
Interna |
jugo Pasando |
Configuring error messages
|
Interna |
jugo Pasando |
Incremental mode
|
Interna |
jugo Pasando |
Advanced options
|
Interna |
jugo Pasando |
Report generation
|
Interna |
jugo Pasando |
Miscellaneous
|
Interna |
jugo Pasando |
Using a pyproject.toml file
|
Interna |
jugo Pasando |
Configuration comment format
|
Interna |
jugo Pasando |
Basic usage
|
Interna |
jugo Pasando |
Daemon client commands
|
Interna |
jugo Pasando |
Additional daemon flags
|
Interna |
jugo Pasando |
Static inference of annotations
|
Interna |
jugo Pasando |
Statically inspect expressions
|
Interna |
jugo Pasando |
Using installed packages with mypy (PEP 561)
|
Interna |
jugo Pasando |
Creating PEP 561 compatible packages
|
Interna |
jugo Pasando |
Integrating mypy into another Python application
|
Interna |
jugo Pasando |
Extending mypy using plugins
|
Interna |
jugo Pasando |
Configuring mypy to use plugins
|
Interna |
jugo Pasando |
High-level overview
|
Interna |
jugo Pasando |
Current list of plugin hooks
|
Interna |
jugo Pasando |
Useful tools
|
Interna |
jugo Pasando |
Specifying what to stub
|
Interna |
jugo Pasando |
Specifying how to generate stubs
|
Interna |
jugo Pasando |
Additional flags
|
Interna |
jugo Pasando |
What stubtest does and does not do
|
Interna |
jugo Pasando |
Example
|
Interna |
jugo Pasando |
Usage
|
Interna |
jugo Pasando |
No errors reported for obviously wrong code
|
Interna |
jugo Pasando |
Spurious errors and locally silencing the checker
|
Interna |
jugo Pasando |
Ignoring a whole file
|
Interna |
jugo Pasando |
Issues with code at runtime
|
Interna |
jugo Pasando |
Mypy runs are slow
|
Interna |
jugo Pasando |
Types of empty collections
|
Interna |
jugo Pasando |
Redefinitions with incompatible types
|
Interna |
jugo Pasando |
Invariance vs covariance
|
Interna |
jugo Pasando |
Declaring a supertype as variable type
|
Interna |
jugo Pasando |
Complex type tests
|
Interna |
jugo Pasando |
Python version and system platform checks
|
Interna |
jugo Pasando |
Displaying the type of an expression
|
Interna |
jugo Pasando |
Silencing linters
|
Interna |
jugo Pasando |
Covariant subtyping of mutable protocol members is rejected
|
Interna |
jugo Pasando |
Dealing with conflicting names
|
Interna |
jugo Pasando |
Using a development mypy build
|
Interna |
jugo Pasando |
Variables vs type aliases
|
Interna |
jugo Pasando |
Incompatible overrides
|
Interna |
jugo Pasando |
Unreachable code
|
Interna |
jugo Pasando |
Narrowing and inner functions
|
Interna |
jugo Pasando |
Runtime definition of methods and functions
|
Interna |
jugo Pasando |
Silencing errors based on error codes
|
Interna |
jugo Pasando |
Enabling/disabling specific error codes globally
|
Interna |
jugo Pasando |
Per-module enabling/disabling error codes
|
Interna |
jugo Pasando |
Subcodes of error codes
|
Interna |
jugo Pasando |
Requiring error codes
|
Interna |
jugo Pasando |
Check that attribute exists [attr-defined]
|
Interna |
jugo Pasando |
Check that attribute exists in each union item [union-attr]
|
Interna |
jugo Pasando |
Check that name is defined [name-defined]
|
Interna |
jugo Pasando |
Check that a variable is not used before it’s defined [used-before-def]
|
Interna |
jugo Pasando |
Check arguments in calls [call-arg]
|
Interna |
jugo Pasando |
Check argument types [arg-type]
|
Interna |
jugo Pasando |
Check calls to overloaded functions [call-overload]
|
Interna |
jugo Pasando |
Check validity of types [valid-type]
|
Interna |
jugo Pasando |
Require annotation if variable type is unclear [var-annotated]
|
Interna |
jugo Pasando |
Check validity of overrides [override]
|
Interna |
jugo Pasando |
Check that function returns a value [return]
|
Interna |
jugo Pasando |
Check that functions don’t have empty bodies outside stubs [empty-body]
|
Interna |
jugo Pasando |
Check that return value is compatible [return-value]
|
Interna |
jugo Pasando |
Check types in assignment statement [assignment]
|
Interna |
jugo Pasando |
Check that assignment target is not a method [method-assign]
|
Interna |
jugo Pasando |
Check type variable values [type-var]
|
Interna |
jugo Pasando |
Check uses of various operators [operator]
|
Interna |
jugo Pasando |
Check indexing operations [index]
|
Interna |
jugo Pasando |
Check list items [list-item]
|
Interna |
jugo Pasando |
Check dict items [dict-item]
|
Interna |
jugo Pasando |
Check TypedDict items [typeddict-item]
|
Interna |
jugo Pasando |
Check TypedDict Keys [typeddict-unknown-key]
|
Interna |
jugo Pasando |
Check that type of target is known [has-type]
|
Interna |
jugo Pasando |
Check for an issue with imports [import]
|
Interna |
jugo Pasando |
Check that import target can be found [import-not-found]
|
Interna |
jugo Pasando |
Check that import target can be found [import-untyped]
|
Interna |
jugo Pasando |
Check that each name is defined once [no-redef]
|
Interna |
jugo Pasando |
Check that called function returns a value [func-returns-value]
|
Interna |
jugo Pasando |
Check instantiation of abstract classes [abstract]
|
Interna |
jugo Pasando |
Safe handling of abstract type object types [type-abstract]
|
Interna |
jugo Pasando |
Check that call to an abstract method via super is valid [safe-super]
|
Interna |
jugo Pasando |
Check the target of NewType [valid-newtype]
|
Interna |
jugo Pasando |
Check the return type of __exit__ [exit-return]
|
Interna |
jugo Pasando |
Check that naming is consistent [name-match]
|
Interna |
jugo Pasando |
Check that literal is used where expected [literal-required]
|
Interna |
jugo Pasando |
Check that overloaded functions have an implementation [no-overload-impl]
|
Interna |
jugo Pasando |
Check that coroutine return value is used [unused-coroutine]
|
Interna |
jugo Pasando |
Warn about top level await expressions [top-level-await]
|
Interna |
jugo Pasando |
Warn about await expressions used outside of coroutines [await-not-async]
|
Interna |
jugo Pasando |
Check types in assert_type [assert-type]
|
Interna |
jugo Pasando |
Check that function isn’t used in boolean context [truthy-function]
|
Interna |
jugo Pasando |
Check that string formatting/interpolation is type-safe [str-format]
|
Interna |
jugo Pasando |
Check for implicit bytes coercions [str-bytes-safe]
|
Interna |
jugo Pasando |
Check that overloaded functions don’t overlap [overload-overlap]
|
Interna |
jugo Pasando |
Notify about an annotation in an unchecked function [annotation-unchecked]
|
Interna |
jugo Pasando |
Report syntax errors [syntax]
|
Interna |
jugo Pasando |
Miscellaneous checks [misc]
|
Interna |
jugo Pasando |
Check that type arguments exist [type-arg]
|
Interna |
jugo Pasando |
Check that every function has an annotation [no-untyped-def]
|
Interna |
jugo Pasando |
Check that cast is not redundant [redundant-cast]
|
Interna |
jugo Pasando |
Check that methods do not have redundant Self annotations [redundant-self]
|
Interna |
jugo Pasando |
Check that comparisons are overlapping [comparison-overlap]
|
Interna |
jugo Pasando |
Check that no untyped functions are called [no-untyped-call]
|
Interna |
jugo Pasando |
Check that function does not return Any value [no-any-return]
|
Interna |
jugo Pasando |
Check that types have no Any components due to missing imports [no-any-unimported]
|
Interna |
jugo Pasando |
Check that statement or expression is unreachable [unreachable]
|
Interna |
jugo Pasando |
Check that expression is redundant [redundant-expr]
|
Interna |
jugo Pasando |
Warn about variables that are defined only in some execution paths [possibly-undefined]
|
Interna |
jugo Pasando |
Check that expression is not implicitly true in boolean context [truthy-bool]
|
Interna |
jugo Pasando |
Check that iterable is not implicitly true in boolean context [truthy-iterable]
|
Interna |
jugo Pasando |
Check that awaitable return value is used [unused-awaitable]
|
Interna |
jugo Pasando |
Check that overrides of mutable attributes are safe [mutable-override]
|
Interna |
jugo Pasando |
Dataclasses
|
Interna |
jugo Pasando |
Data Class Transforms
|
Interna |
jugo Pasando |
The attrs package
|
Interna |
jugo Pasando |
Using a remote cache to speed up mypy runs
|
Interna |
jugo Pasando |
Extended Callable types
|
Interna |
jugo Pasando |
Why have both dynamic and static typing?
|
Interna |
jugo Pasando |
Would my project benefit from static typing?
|
Interna |
jugo Pasando |
Can I use mypy to type check my existing Python code?
|
Interna |
jugo Pasando |
Will static typing make my programs run faster?
|
Interna |
jugo Pasando |
Is mypy free?
|
Interna |
jugo Pasando |
Can I use duck typing with mypy?
|
Interna |
jugo Pasando |
I like Python and I have no need for static typing
|
Interna |
jugo Pasando |
How are mypy programs different from normal Python?
|
Interna |
jugo Pasando |
How is mypy different from Cython?
|
Interna |
jugo Pasando |
Does it run on PyPy?
|
Interna |
jugo Pasando |
Mypy is a cool project. Can I help?
|
Interna |
jugo Pasando |
¶
|
Interna |
jugo Pasando |
Sphinx
|
Externa |
jugo Pasando |
@pradyunsg
|
Externa |
jugo Pasando |
Furo
|
Externa |
jugo Pasando |
Welcome to mypy documentation!
|
Interna |
jugo Pasando |