This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tfish2
Recipients Nathaniel Manista, docs@python, rhettinger, tfish2
Date 2022-03-25.21:57:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The problem with PEP-484 is that if one wants to use static type analysis, neither of these options are good:

- Use static annotations on functions, and additionally spec
  out expectations in docstrings. Do note that the two types places
  where "float" is mentioned here refer to different concepts.
  This looks as if there were duplication, but there actually
  isn't, since the claims are different. This is confusing as hell.

def foo(x: float) -> float:
  """Foos the barbaz

    x: float, the foobar
    float, the foofoo"""

The floats in the docstring give me a guarantee: "If I feed in a float, I am guaranteed to receive back a float". The floats in the static type annotation merely say "yeah, can be float or int, and I'd call it ok in these cases" - that's a very different statement.

- Just go with static annotations, drop mention of types
  from docstrings, and accept that we lose the ability to
  stringently reason about the behavior of code.

With respect to this latter option, I think we can wait for "losing the ability to stringently reason about the behavior of code" to cause major security headaches. That's basically opening up the door to many problems at the level of "I can crash the webserver by requesting the url http://lpt1".
Date User Action Args
2022-03-25 21:57:44tfish2setrecipients: + tfish2, rhettinger, docs@python, Nathaniel Manista
2022-03-25 21:57:44tfish2setmessageid: <>
2022-03-25 21:57:44tfish2linkissue47121 messages
2022-03-25 21:57:44tfish2create