Skip to content

query_param decorator does not preserve signature #736

Closed
@beniwohli

Description

@beniwohli

The query_param decorator is used on pretty much all client methods. It uses functools.wraps to copy __module__, __name__, __doc__ etc. Unfortunately, wraps does not preserve the signature of the wrapped function, so inspect.getargspec() and friends become pretty much useless (inspect.signature() works but only in Python 3.5+, and only because it cheats).

This makes it difficult for e.g. code completion in IDEs to work correctly. On a more egoistic note, it also makes it more difficult for things like Elastic APM to introspect the client 😊

Preserving the signature is a bit less trivial than preserving __doc__ etc, but there are a few utilities that could help:

There's also wrapt, but that might be a bit too heavy just to preserve the signature.

We could either add one of the two libraries as a dependency, or vendor them (they are both BSD).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions