[Python-ideas] Optional static typing -- late to the party

Ben Finney ben+python at benfinney.id.au
Wed Aug 20 22:29:16 CEST 2014


Chris Angelico <rosuav at gmail.com> writes:

> On Wed, Aug 20, 2014 at 10:53 PM, Ben Finney <ben+python at benfinney.id.au> wrote:
> > Steven D'Aprano <steve at pearwood.info> writes:
> >
> >> But remember that any annotations in docstrings may not be
> >> available at runtime
> >
> > How so? What conformant Python implementation is discarding
> > docstrings from code objects?
>
> CPython with the -OO flag. Or is that non-conformant?

Okay, one can deliberately remove docstrings with an option to the
interpreter (the “-OO” option explicitly has that purpose). So a user
wanting to check annotations in docstrings wouldn't use that option. So
this case doesn't seem relevant to the discussion.

Remember that we're talking about type annotations that are for
*static code checkers* to inspect. Docstrings will certainly be
available there.

-- 
 \        “… no testimony can be admitted which is contrary to reason; |
  `\   reason is founded on the evidence of our senses.” —Percy Bysshe |
_o__)                        Shelley, _The Necessity of Atheism_, 1811 |
Ben Finney



More information about the Python-ideas mailing list