antlr / antlr4

ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.
http://antlr.org
BSD 3-Clause "New" or "Revised" License
17.26k stars 3.29k forks source link

Python 3: PEP 561 py.typed #2868

Open atollk opened 4 years ago

atollk commented 4 years ago

PEP 561 for Python 3 recommends adding an empty "py.typed" file to a package for type hints to be found. This is required for tools such as mypy.

ericvergnaud commented 4 years ago

Hi,

am I incorrect in thinking that for Python 3 inline type hints are preferred, and PEP 561 is more about Python 2?

atollk commented 4 years ago

@ericvergnaud PEP 561 was defined for Python 3.7. For a package to have proper type checking support nowadays, both inline typing (or typed stubs) and the py.typed file described in the PEP have to be present.

In other words, mypy will report an error on imports of Antlr, even though it offers inline type hints, because it does not follow PEP 561.