Python Sanity Proposal: Type Hinting Solution

Chris Angelico rosuav at
Fri Jan 23 06:31:55 CET 2015

On Fri, Jan 23, 2015 at 4:03 PM, Terry Reedy <tjreedy at> wrote:
> On 1/22/2015 10:59 PM, Chris Angelico wrote:
>> On Fri, Jan 23, 2015 at 2:22 PM, Terry Reedy <tjreedy at> wrote:
>>> This idea is so brilliant that it is already an option in mypy and is
>>> part
>>> of the new type-hint proposal.  The separate type-hint files are called
>>> 'stub files'.
>> It's worth pointing out, too, that the idea isn't panaceaic - it's
>> just another tool in the box. Any time you break related things into
>> separate places, especially separate files, the tendency for them to
>> get out of sync grows dramatically.
> The same could be said of putting tests in a separate file.

Yep. It's not a killer, but it does have a cost. That's one reason for
doctests - to put the tests in with the code. Everything's a
trade-off; with tests it's often better to put them in another file,
but type hints are short and compact, and can be briefly stated.
Unlike the complicated ones this thread has given us, most real-world
ones will be short. So we have the option to put them in-line or out
of line, and the two options have competing costs (readability vs code


More information about the Python-list mailing list