[Python-ideas] PEP 484 evolution
Alexander Walters
tritium-list at sdamon.com
Sat Mar 19 22:21:26 EDT 2016
On 3/19/2016 21:58, Chris Angelico wrote:
> Stub files have *never* been the only option, for the same reason that
> external documentation is not a replacement for docstrings. Keeping
> information near the code it's connected to gives it a FAR better
> chance of staying current than having it out-of-line does. Stub files
> are supported for those times when it's impossible or inadvisable to
> use inline annotations (eg for Py2 compatibility - the comments are
> ugly compared to the proper annotations), but the preferred way to
> provide type hints is to use the PEP 3107 annotation syntax.
>
> ChrisA
>
I don't exactly see how stub files would be any different than tests in
this regard. Unless I am totally misunderstanding something, the type
hints only exist to make static analysis by tools (presumably in a test
suite) easier. Why would a failing static analysis check go unnoticed
and not the a test? Why is there no argument to integrate the test
suite into the module under test, by the same logic?
When documentation does not get updated to reflect the reality of the
code, a test run does not fail, a task does not turn red in CI, tools
don't return non-zero. If you care about type-hints, keeping hints in
stub files, and not updating those stubs, breaks things. Why muck up the
code for people who don't care about type hints?
More information about the Python-ideas
mailing list