-
Hi, I seem to have problems with chanining decorators from __future__ import annotations
from typing import Callable
import functools
def decorator(func: Callable[[int, str], None]) -> Callable[[int, str], None]:
@functools.wraps(func)
def func_wrapper(firstarg: int, secondarg: str) -> None:
return func(firstarg, secondarg)
return func_wrapper
class Test:
def __init__(self):
self.test(1, 'a')
@staticmethod
@decorator
def test(firstarg: int, secondarg: str) -> None:
print(firstarg, secondarg)
Test() This code works, but pyright reports that test() has only one expected arg instead of 2. It probably thinks it needs to strip away "self"? but as its a staticmethod this is not the case. Or maybe i typed the decorator wrong |
Beta Was this translation helpful? Give feedback.
Answered by
erictraut
Jan 11, 2022
Replies: 1 comment
-
Yeah, pyright is treating it as though you had applied |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
lovetox
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah, pyright is treating it as though you had applied
@decorator
after the@staticmethod
rather than the other way around. I'll create a bug report for this.