◐ Shell
clean mode source ↗

handle type annotations in nested functions correctly by elmjag · Pull Request #7072 · RustPython/RustPython

coderabbitai[bot]

Bot reviewed Feb 10, 2026

For example in the following code:

    def foo(x: int, y: float):
        def bar(q: int):
            return q
        pass

Make sure that `foo` type annotations are correctly propogated to
it's `__annotate__` and `__annotations__` attributes.

With this chage, we'll get:

    >>>>> foo.__annotations__
    {'x': <class 'int'>, 'y': <class 'float'>}

Previously annotations where 'lost', and we would get:

    >>>>> foo.__annotations__
    {}

youknowone

@elmjag elmjag deleted the nested-funcs-annotations branch

February 12, 2026 13:46

youknowone pushed a commit to youknowone/RustPython that referenced this pull request

Mar 22, 2026
For example in the following code:

    def foo(x: int, y: float):
        def bar(q: int):
            return q
        pass

Make sure that `foo` type annotations are correctly propogated to
it's `__annotate__` and `__annotations__` attributes.

With this chage, we'll get:

    >>>>> foo.__annotations__
    {'x': <class 'int'>, 'y': <class 'float'>}

Previously annotations where 'lost', and we would get:

    >>>>> foo.__annotations__
    {}