Skip to content

Types for return type #353

Description

@danielpassy

Is your feature request related to a problem? Please describe.
Proper typing on return type of methods

from uplink import Consumer, post

class Client(Consumer):
    @post("example")
    def example_method(self) -> list[int]:
        pass

a = Client().example_method

you can verify the return type with mypy with one single command:

uv run --python 3.12 --with 'uplink[aiohttp]>=0.10.0' --with mypy mypy --python-version 3.12 --ignore-missing-imports --disable-error-code empty-body -c $'from uplink import Consumer, post\n\nclass Client(Consumer):\n    @post("example")\n    def example_method(self) -> list[int]: ...\n\na = Client().example_method\nreveal_type(a)'

yes, this iwas generated by AI, but that just run python 3.12 with uplink[aiohttp]>=0.10.0' and mypy (latest) and verify the return of the var a on the previous code snippet

<string>:8: note: Revealed type is "Any"
Success: no issues found in 1 source file

it's Any, not list[int] as expected.

Describe the solution you'd like
I honestly don't know. This is open to discussion

This lib is kind of abandoned, so I'm not sure if a refactor is worth it.
OtOH, I asked AI to one shot type stubs and it came up with this
https://github.com/danielpassy/uplink-stubs

Additional context
Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions