Feature
PEP 749 specifies writable __annotate__ and __annotations__ attributes for classmethod and staticmethod. Reading should retrieve and cache the wrapped callable's value in the wrapper's __dict__; writing should update only the wrapper, not the wrapped callable.
Minimal reproduction:
def f() -> Missing:
pass
for wrapper in (classmethod(f), staticmethod(f)):
Missing = int
print(type(wrapper).__name__, wrapper.__annotations__)
print("__annotations__" in wrapper.__dict__)
wrapper.__annotations__ = {"x": str}
print("wrapper:", wrapper.__annotations__)
print("wrapped:", f.__annotations__)
CPython 3.14.6 caches __annotations__ in each wrapper and leaves f.__annotations__ unchanged after assignment.
RustPython does not cache the delegated value in the wrapper for the unresolved-name case, and assignment mutates the wrapped function's annotations. This is already represented by the expectedFailure marker on ClassPropertiesAndMethods.test_classmethod_staticmethod_annotations in Lib/test/test_descr.py.
Python Documentation or reference to CPython source code
Feature
PEP 749 specifies writable
__annotate__and__annotations__attributes forclassmethodandstaticmethod. Reading should retrieve and cache the wrapped callable's value in the wrapper's__dict__; writing should update only the wrapper, not the wrapped callable.Minimal reproduction:
CPython 3.14.6 caches
__annotations__in each wrapper and leavesf.__annotations__unchanged after assignment.RustPython does not cache the delegated value in the wrapper for the unresolved-name case, and assignment mutates the wrapped function's annotations. This is already represented by the
expectedFailuremarker onClassPropertiesAndMethods.test_classmethod_staticmethod_annotationsinLib/test/test_descr.py.Python Documentation or reference to CPython source code
__annotations__”: https://peps.python.org/pep-0749/#wrappers-that-provide-annotations