Skip to content

Allow IDEs to autocomplete method signatures #192

@DefiDebauchery

Description

@DefiDebauchery

When directly using methods decorated with @endpoint, IDEs won't read and recommend arguments:

    @endpoint('/v2/delegates')
    async def get_delegates(self, query_params: V2DelegatesFilter) -> SafeDelegateResponse:
        ...

This makes it difficult to remember what params are used. (I don't mind instantiating the Pydantic Filter since it autocompletes, but the IDE won't even tell me that this method requires V2DelegatesFilter)

The workarounds to this all require duplication:

  1. Rename decorated method to be internal and add a public one with the
  2. Duplicate the Filter as a TypedDict and use typing.Union (which might work with meatie if it handles TypedDicts, but foregoes the Pydantic-specific methods my BaseFilter has, including the custom unwrap())
  3. Define stubs in a .pyi file.

My (very rudimentary) understanding is that the decorator needs to do something with the function signature, but I was personally unable to work out how to make that happen.

Unsure if this is feasible to do, but any 'auto-magic' ways to interact with the endpoints in my IDE would be really helpful!

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions