Skip to content

Twice-forwarded args and kwargs #7975

Answered by erictraut
dpmccabe asked this question in Q&A
Discussion options

You must be logged in to vote

Pyright is doing the right thing here. For comparison, mypy emits the same error.

One workaround is to replace the object annotations with Any in the call_api signature.

If you want to retain more type safety, you can do the following:

def call_api(
    func: Callable[P, R], max_attempts: int = 0, *args: P.args, **kwargs: P.kwargs
) -> R:
    return maybe_retry(
        func,
        retryable_exceptions=(requests.ConnectionError, requests.ConnectTimeout),
        max_attempts=max_attempts,
        *args,
        **kwargs,
    )

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@dpmccabe
Comment options

Answer selected by dpmccabe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants