#566 Take advantage of Python 3 function annotations

open
nobody
5
2012-02-14
2012-02-14
No

Python 3 introduced function annotations in PEP 3107. One idea of how to use them is to specify argument and return types. This can be very useful for code completion. For example if we have a function defined as `def f(x: str)`, we can assume that x will actually be of type str and complete with methods for that class.

Discussion

  • Eike Welk

    Eike Welk - 2012-03-06

    This would be definitely great in conjunction with a type checking decorator. Pydev should have special knowledge about the decorator. If the decorator is present, it should use the function annotations for its type inference algorithm.

    However Pydev should not always interpret function annotations as type declarations, because these annotations can be anything. For example other kinds of tests, such as requirements. Or they could be documentation.

     
  • Remigiusz 'lRem' Modrzejewski

    True. But when provided with a normal class (with no special annotation intent), we can safely assume that x:str means that x will be a string...