from annotationlib import Format
from collections.abc import Mapping
from typing import Any, Protocol
class CanAnnotate(Protocol):
def __annotate__(self, format: Format, /) -> Mapping[str, Any]: ...
Traceback (most recent call last):
File "/home/joren/.local/share/uv/python/cpython-3.14.3-linux-x86_64-gnu/lib/python3.14/typing.py", line 1853, in _get_protocol_attrs
annotations = base.__annotations__
^^^^^^^^^^^^^^^^^^^^
TypeError: CanAnnotate.__annotate__() missing 1 required positional argument: 'format'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/joren/Workspace/optype/repro.py", line 6, in <module>
class CanAnnotate(Protocol):
def __annotate__(self, format: Format, /) -> Mapping[str, Any]: ...
File "/home/joren/.local/share/uv/python/cpython-3.14.3-linux-x86_64-gnu/lib/python3.14/typing.py", line 1999, in __init__
cls.__protocol_attrs__ = _get_protocol_attrs(cls)
~~~~~~~~~~~~~~~~~~~^^^^^
File "/home/joren/.local/share/uv/python/cpython-3.14.3-linux-x86_64-gnu/lib/python3.14/typing.py", line 1856, in _get_protocol_attrs
annotations = _lazy_annotationlib.get_annotations(
base, format=_lazy_annotationlib.Format.FORWARDREF
)
File "/home/joren/.local/share/uv/python/cpython-3.14.3-linux-x86_64-gnu/lib/python3.14/annotationlib.py", line 982, in get_annotations
ann = _get_and_call_annotate(obj, format)
File "/home/joren/.local/share/uv/python/cpython-3.14.3-linux-x86_64-gnu/lib/python3.14/annotationlib.py", line 1121, in _get_and_call_annotate
ann = call_annotate_function(annotate, format, owner=obj)
File "/home/joren/.local/share/uv/python/cpython-3.14.3-linux-x86_64-gnu/lib/python3.14/annotationlib.py", line 720, in call_annotate_function
return annotate(format)
TypeError: CanAnnotate.__annotate__() missing 1 required positional argument: 'format'
Bug report
Bug description:
On Python 3.14.3 and 3.15.0a7 this results in a
TypeError:On Python 3.13 (when you replace the
annotationlib.FormatwithAny), there is no error.CPython versions tested on:
3.14
Operating systems tested on:
Linux