Top "Mypy" questions

Mypy is an optional static type checker for Python.

How can I specify the function type in my type hints?

I want to use type hints in my current Python 3.5 project. My function should receive a function as parameter. How …

python python-3.x python-3.5 type-hinting mypy
How can mypy ignore a single line in a source file?

I'm using mypy in my python project for type checking. I'm also using PyYAML for reading and writing the project …

python types mypy
Specifying a type to be a List of numbers (ints and/or floats)?

How do I specific a function can take a list of numbers which can be ints or floats? I tried …

python types type-hinting mypy
Python equivalent of Typescript interface

Recently I have been working with Typescript a lot, it allows to express things like: interface Address { street: string; housenumber: …

python typescript static-typing mypy
How to use type hints in python 3.6?

I noticed python 3.5 and python 3.6 added a lot of features about static type checking, so I tried with the following …

python python-3.x type-hinting python-3.6 mypy
Mypy error - incompatible types in assignment

My function looks like this simplified code sample: def my_func() -> dict: result = {"success": False} if condition: result["…

python mypy
mypy, type hint: Union[float, int] -> is there a Number type?

mypy is really handy and catches a lot of bugs, but when I write "scientific" applications, I often end up …

python type-hinting mypy union-types
Need type annotation for variable in python 3.5 code

I am using mypy on my python 3.5 code, and I got a lot of messages which look like this: file:…

python python-3.x type-hinting mypy
Python type hints and context managers

How should a context manager be annotated with Python type hints? import typing @contextlib.contextmanager def foo() -> ???: yield …

python mypy
Specify length of Sequence or List with Python typing module

I'm giving the Python typing module a shot. I know that it's valid to specify the length of a List …

python python-3.x type-hinting mypy