Skip to content

Commit c04dc0c

Browse files
committed
reduce the diff
1 parent db1ba63 commit c04dc0c

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

mypy/stubgen.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -501,39 +501,39 @@ def _get_func_args(self, o: FuncDef, ctx: FunctionContext) -> list[ArgSig]:
501501
args.append(ArgSig(name, typename, default=bool(arg_.initializer)))
502502
return args
503503

504-
def _get_func_return(self, func_def: FuncDef, ctx: FunctionContext) -> str | None:
505-
if func_def.name != "__init__" and isinstance(func_def.unanalyzed_type, CallableType):
506-
if isinstance(get_proper_type(func_def.unanalyzed_type.ret_type), AnyType):
504+
def _get_func_return(self, o: FuncDef, ctx: FunctionContext) -> str | None:
505+
if o.name != "__init__" and isinstance(o.unanalyzed_type, CallableType):
506+
if isinstance(get_proper_type(o.unanalyzed_type.ret_type), AnyType):
507507
# Luckily, a return type explicitly annotated with "Any" has
508508
# type "UnboundType" and will enter the else branch.
509509
return None # implicit Any
510510
else:
511-
return self.print_annotation(func_def.unanalyzed_type.ret_type)
512-
if func_def.abstract_status == IS_ABSTRACT or func_def.name in METHODS_WITH_RETURN_VALUE:
511+
return self.print_annotation(o.unanalyzed_type.ret_type)
512+
if o.abstract_status == IS_ABSTRACT or o.name in METHODS_WITH_RETURN_VALUE:
513513
# Always assume abstract methods return Any unless explicitly annotated. Also
514514
# some dunder methods should not have a None return type.
515515
return None # implicit Any
516-
retname = infer_method_ret_type(func_def.name)
516+
retname = infer_method_ret_type(o.name)
517517
if retname is not None:
518518
return retname
519-
if has_yield_expression(func_def) or has_yield_from_expression(func_def):
519+
if has_yield_expression(o) or has_yield_from_expression(o):
520520
self.add_typing_import("Generator")
521521
yield_name = "None"
522522
send_name = "None"
523523
return_name = "None"
524-
if has_yield_from_expression(func_def):
524+
if has_yield_from_expression(o):
525525
yield_name = send_name = self.add_typing_import("Incomplete")
526526
else:
527-
for expr, in_assignment in all_yield_expressions(func_def):
527+
for expr, in_assignment in all_yield_expressions(o):
528528
if expr.expr is not None and not is_none_expr(expr.expr):
529529
yield_name = self.add_obj_import("_typeshed", "Incomplete", require=True)
530530
if in_assignment:
531531
send_name = self.add_obj_import("_typeshed", "Incomplete", require=True)
532-
if has_return_statement(func_def):
532+
if has_return_statement(o):
533533
return_name = self.add_obj_import("_typeshed", "Incomplete", require=True)
534534
generator_name = self.add_typing_import("Generator")
535535
return f"{generator_name}[{yield_name}, {send_name}, {return_name}]"
536-
if not has_return_statement(func_def) and func_def.abstract_status == NOT_ABSTRACT:
536+
if not has_return_statement(o) and o.abstract_status == NOT_ABSTRACT:
537537
return "None"
538538
return None
539539

0 commit comments

Comments
 (0)