gh-119180: Rename parameter to __annotate__ functions by JelleZijlstra · Pull Request #124461 · python/cpython
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use a dundered name because dundered name are reserved to the implementation. Users could use a class named _format in their annotations.
The current PR has this behavior:
>>> def f(x: __format__): pass
...
>>> f.__annotations__
{'x': 1}
I think with a dunder name we can handwave that away with "don't do that", but a user could reasonably use the name _format.
Still we could use a different name like __fmt__ or __annotate__ (I think Larry suggested the latter, but that name feels more confusing than __format__).