Summary
RustPython function type annotations order does not match Python when accessed via __annotations__.
This causes problems with e.g. functools singledispatch which assumes the types in annotations are in order of leftmost parameter to return type. dataclasses and pydantic are other libraries which could be affected by this. It this is fixed a lot of importlib tests can be updated to python 3.13 as they have started using singledispatch in Lib/importlib/resources/_common.py.
Sample code
str parameter and int return type.
def func(s: str) -> int:
return int(s)
print(func.__annotations__)
Expected
{'s': <class 'str'>, 'return': <class 'int'>}
Actual
{'return': <class 'int'>, 's': <class 'str'>}
Summary
RustPython function type annotations order does not match Python when accessed via
__annotations__.This causes problems with e.g. functools
singledispatchwhich assumes the types in annotations are in order of leftmost parameter to return type.dataclassesandpydanticare other libraries which could be affected by this. It this is fixed a lot of importlib tests can be updated to python 3.13 as they have started using singledispatch in Lib/importlib/resources/_common.py.Sample code
strparameter andintreturn type.Expected
{'s': <class 'str'>, 'return': <class 'int'>}Actual
{'return': <class 'int'>, 's': <class 'str'>}