mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Fix signatures for wraps, see #1058
This commit is contained in:
@@ -179,6 +179,41 @@ def test_pow_signature(Script):
|
||||
'pow(x: int, y: int, /) -> Any'}
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'code, signature', [
|
||||
[dedent('''
|
||||
import functools
|
||||
def f(x):
|
||||
pass
|
||||
def x(f):
|
||||
@functools.wraps(f)
|
||||
def wrapper(*args):
|
||||
# Have no arguments here, but because of wraps, the signature
|
||||
# should still be f's.
|
||||
return f(*args)
|
||||
return wrapper
|
||||
|
||||
x(f)('''), 'f(x, /)'],
|
||||
[dedent('''
|
||||
import functools
|
||||
def f(x):
|
||||
pass
|
||||
def x(f):
|
||||
@functools.wraps(f)
|
||||
def wrapper():
|
||||
# Have no arguments here, but because of wraps, the signature
|
||||
# should still be f's.
|
||||
return 1
|
||||
return wrapper
|
||||
|
||||
x(f)('''), 'f()'],
|
||||
]
|
||||
)
|
||||
def test_wraps_signature(Script, code, signature, skip_pre_python35):
|
||||
sigs = Script(code).call_signatures()
|
||||
assert {sig._signature.to_string() for sig in sigs} == {signature}
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'start, start_params', [
|
||||
['@dataclass\nclass X:', []],
|
||||
|
||||
Reference in New Issue
Block a user