Files
RustPython/extra_tests/snippets/syntax_annotations.py
Jack O'Connor 33ea50c2e9 Add return annotation to __annotations__ last (#6071)
Functions like `functools.singledispatch` are sensitive to the order of
items in the `__annotations__` map.

CPython puts returns last.
2025-08-08 23:31:12 +09:00

11 lines
257 B
Python

from typing import get_type_hints
def func(s: str) -> int:
return int(s)
hints = get_type_hints(func)
# The order of type hints matters for certain functions
# e.g. functools.singledispatch
assert list(hints.items()) == [('s', str), ('return', int)]