8000 stubgen: Don't generate `Incomplete | None = None` argument annotation by srittau · Pull Request #19097 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

stubgen: Don't generate Incomplete | None = None argument annotation #19097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 16, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Make can_be_incomplete kwonly
  • Loading branch information
srittau committed May 16, 2025
commit 804f2cb736f09e18c90f8052b03cb7506dc37cbe
4 changes: 2 additions & 2 deletions mypy/stubgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ def _get_func_args(self, o: FuncDef, ctx: FunctionContext) -> list[ArgSig]:
default = "..."
if arg_.initializer:
if not typename:
typename = self.get_str_type_of_node(arg_.initializer, False)
typename = self.get_str_type_of_node(arg_.initializer, can_be_incomplete=False)
potential_default, valid = self.get_str_default_of_node(arg_.initializer)
if valid and len(potential_default) <= 200:
default = potential_default
Expand Down Expand Up @@ -1305,7 +1305,7 @@ def is_private_member(self, fullname: str) -> bool:
parts = fullname.split(".")
return any(self.is_private_name(part) for part in parts)

def get_str_type_of_node(self, rvalue: Expression, can_be_incomplete: bool = True) -> str:
def get_str_type_of_node(self, rvalue: Expression, *, can_be_incomplete: bool = True) -> str:
rvalue = self.maybe_unwrap_unary_expr(rvalue)

if isinstance(rvalue, IntExpr):
Expand Down
0