Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:
+1 for a command-line option decouples this from eliminating docstrings. The latter generally has no semantic effect, but the former might. Ideally, we don't want to break non-typing uses of annotations. One example below uses annotations for argument validation and documentation. Another example would be the using __annotations__ for dynamic dispatch. --- Example ----------------------------------------------------------- >>> class Limit: def __init__(self, low, high): self.low = low self.high = high def valid(self, x): return self.low <= x <= self.high def __repr__(self): return f'{type(self).__name__}(low={self.low}, high={self.high})' >>> def validate(function, parameter, value): assert function.__annotations__[parameter].valid(value) >>> def maneuver(thrust: Limit(100, 150), angle: Limit(-10, 20)): 'Engage OMS burn (orbital maneuvering system).' validate(maneuver, 'thrust', thrust) validate(maneuver, 'angle', angle) ... >>> help(maneuver) Help on function maneuver in module __main__: maneuver(thrust: Limit(low=100, high=150), angle: Limit(low=-10, high=20)) Engage OMS burn (orbital maneuvering system). >>> maneuver(120, 7) >>> maneuver(120, 35) Traceback (most recent call last): File "<pyshell#41>", line 1, in <module> maneuver(120, 35) File "<pyshell#38>", line 4, in maneuver validate(maneuver, 'angle', angle) File "<pyshell#30>", line 2, in validate assert function.__annotations__[parameter].valid(value) AssertionError ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36466> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com