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

Use float only, as int is implied in that type: def my_func(number: float): PEP 484 Type Hints specifically states that: Rather than requiring that users write import numbers and then use numbers.Float etc., this PEP proposes a straightforward shortcut that is almost as effective: when an argument is annotated as having type float, an argument … Read more

What is the type hint for a (any) python module?

and types.ModuleType() is a constructor. That doesn’t matter. types.ModuleType is still a reference to a type, just like str and int are. There is no need for a generic Module[typehint] annotation, so types.ModuleType is exacly what you need to use here. For example, the official Python typeshed project provides a type hint annotation for sys.modules … Read more

Type hinting / annotation (PEP 484) for numpy.ndarray

Update Check recent numpy versions for a new typing module https://numpy.org/doc/stable/reference/typing.html#module-numpy.typing dated answer It looks like typing module was developed at: https://github.com/python/typing The main numpy repository is at https://github.com/numpy/numpy Python bugs and commits can be tracked at http://bugs.python.org/ The usual way of adding a feature is to fork the main repository, develop the feature till … Read more