forked from VimPlug/jedi
Merge pull request #1614 from PeterJCLaw/fix-decorator-factory-passthrough
Support passing values through decorators from factories
This commit is contained in:
@@ -281,7 +281,8 @@ def infer_return_for_callable(arguments, param_values, result_values):
|
||||
|
||||
return ValueSet.from_sets(
|
||||
v.define_generics(all_type_vars)
|
||||
if isinstance(v, (DefineGenericBaseClass, TypeVar)) else ValueSet({v})
|
||||
if isinstance(v, (DefineGenericBaseClass, TypeVar))
|
||||
else ValueSet({v})
|
||||
for v in result_values
|
||||
).execute_annotation()
|
||||
|
||||
|
||||
@@ -230,6 +230,87 @@ is_decorated(the_para
|
||||
)
|
||||
|
||||
|
||||
class class_decorator_factory_plain:
|
||||
def __call__(self, func: T) -> T:
|
||||
...
|
||||
|
||||
#? class_decorator_factory_plain()
|
||||
class_decorator_factory_plain()
|
||||
|
||||
#?
|
||||
class_decorator_factory_plain()()
|
||||
|
||||
is_decorated_by_class_decorator_factory = class_decorator_factory_plain()(will_be_decorated)
|
||||
|
||||
#? will_be_decorated
|
||||
is_decorated_by_class_decorator_factory
|
||||
|
||||
#? ['the_param=']
|
||||
is_decorated_by_class_decorator_factory(the_par
|
||||
)
|
||||
|
||||
|
||||
def decorator_factory_plain() -> Callable[[T], T]:
|
||||
pass
|
||||
|
||||
#? Callable()
|
||||
decorator_factory_plain()
|
||||
|
||||
#?
|
||||
decorator_factory_plain()()
|
||||
|
||||
#? int()
|
||||
decorator_factory_plain()(42)
|
||||
|
||||
is_decorated_by_plain_factory = decorator_factory_plain()(will_be_decorated)
|
||||
|
||||
#? will_be_decorated
|
||||
is_decorated_by_plain_factory
|
||||
|
||||
#? ['the_param=']
|
||||
is_decorated_by_plain_factory(the_par
|
||||
)
|
||||
|
||||
|
||||
class class_decorator_factory_bound_callable:
|
||||
def __call__(self, func: TCallable) -> TCallable:
|
||||
...
|
||||
|
||||
#? class_decorator_factory_bound_callable()
|
||||
class_decorator_factory_bound_callable()
|
||||
|
||||
#? Callable()
|
||||
class_decorator_factory_bound_callable()()
|
||||
|
||||
is_decorated_by_class_bound_factory = class_decorator_factory_bound_callable()(will_be_decorated)
|
||||
|
||||
#? will_be_decorated
|
||||
is_decorated_by_class_bound_factory
|
||||
|
||||
#? ['the_param=']
|
||||
is_decorated_by_class_bound_factory(the_par
|
||||
)
|
||||
|
||||
|
||||
def decorator_factory_bound_callable() -> Callable[[TCallable], TCallable]:
|
||||
pass
|
||||
|
||||
#? Callable()
|
||||
decorator_factory_bound_callable()
|
||||
|
||||
#? Callable()
|
||||
decorator_factory_bound_callable()()
|
||||
|
||||
is_decorated_by_bound_factory = decorator_factory_bound_callable()(will_be_decorated)
|
||||
|
||||
#? will_be_decorated
|
||||
is_decorated_by_bound_factory
|
||||
|
||||
#? ['the_param=']
|
||||
is_decorated_by_bound_factory(the_par
|
||||
)
|
||||
|
||||
|
||||
class That(Generic[T]):
|
||||
def __init__(self, items: List[Tuple[str, T]]) -> None:
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user