Skip to content
Search

PEP 484

lastmod 2022-12-21created 2021-02-245 edits

PEP 484 -- Type Hints.

Exceptions

  • # type: ignore comment
  • @no_type_check decorator on a class or function
  • Custom class or Function decorator marked with @no_type_check_decorator

Stub Files

Stub files are files containing type hints that are only for use by the type checker, not at runtime. There are several use cases for stub files:

  • Extension modules
  • Third-party modules whose authors have not yet added type hints
  • Standard library modules for which type hints have not yet been written
  • Modules that must be compatible with Python 2 and 3
  • Modules that use annotations for other purposes

How to create them

Simply, if mypy is installed:

mkdir out
stubgen -m cv2 -o out

See mypy:stubgen for details.

Other libraries include:

This is typically used when PyCharm cannot find cv2 symbols.

See also

Favorite site

author Zer0 sitemap