mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-06 12:14:28 +08:00
Perform anal_type for arguments and return type when copying methods to another class (#279)
* Found the reproducible test case * fix import resolution for method copy * remove irrelevant parts from test * fix mypy errors Co-authored-by: Boger <kotvberloge@gmail.com>
This commit is contained in:
@@ -327,6 +327,14 @@ def _prepare_new_method_arguments(node: FuncDef) -> Tuple[List[Argument], MypyTy
|
||||
def copy_method_to_another_class(ctx: ClassDefContext, self_type: Instance,
|
||||
new_method_name: str, method_node: FuncDef) -> None:
|
||||
arguments, return_type = _prepare_new_method_arguments(method_node)
|
||||
|
||||
semanal_api = get_semanal_api(ctx)
|
||||
for argument in arguments:
|
||||
if argument.type_annotation is not None:
|
||||
argument.type_annotation = semanal_api.anal_type(argument.type_annotation)
|
||||
if return_type is not None:
|
||||
return_type = semanal_api.anal_type(return_type) or AnyType(TypeOfAny.unannotated)
|
||||
|
||||
add_method(ctx,
|
||||
new_method_name,
|
||||
args=arguments,
|
||||
|
||||
Reference in New Issue
Block a user