mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 11:53:49 +07:00
Removed a number of tests in Py3TypeTest duplicating those of PyDecoratedFunctionTypeProviderTest. Removed the tests about PY-23067 in Py3ArgumentListInspectionTest and Py3CompletionTest because this issue was actually not addressed in 05e8ed4df0c7faa24bd972e1b422f664d708b510, and the behavior some of them assert is not what users wanted. More consistent naming of tests in PyDecoratedFunctionTypeProviderTest and PyParameterInfoTest. Removed there excess tests too similar to others or checking scenarios not relevant to the current approach to type inference for decorators, e.g. presense of @functools.wraps and alternatives inside decorators — we don't even analyze their bodies anymore. Add a few extra tests illustrating problems with the current approach: - testNotAnnotatedDecoratorChangingFunctionSignatureIsIgnored - testInStackOfDecoratorsChangingFunctionSignatureOnlyAnnotatedAreConsidered - testInStackOfImportedDecoratorsChangingFunctionSignatureOnlyAnnotatedAreConsidered - testNotAnnotatedDecoratorRetainsParametersOfOriginalFunctionEvenIfItChangesItsSignature GitOrigin-RevId: 0bf5070fc523b88dcc9d3009786dd028bdfa0feb
23 lines
504 B
Python
23 lines
504 B
Python
import functools
|
|
from typing import Callable, ParamSpec, TypeVar, Concatenate
|
|
|
|
|
|
P = ParamSpec("P")
|
|
R = TypeVar("R")
|
|
|
|
|
|
def decorator(func: Callable[P, R]) -> Callable[Concatenate[str, P], R]:
|
|
@functools.wraps(func)
|
|
def wrapper(input_c: str, input_a: int, input_b: float):
|
|
print("using_decorator")
|
|
return func(input_a, input_b)
|
|
return wrapper
|
|
|
|
|
|
@decorator
|
|
def function(input_a: int, input_b: float):
|
|
return input_a + input_b
|
|
|
|
|
|
if __name__ == '__main__':
|
|
function(<arg1>) |