8000 Provide hint when Union type with None may not have been narrowed by angelawuuu · Pull Request #17178 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Provide hint when Union type with None may not have been narrowed #17178

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

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
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
Next Next commit
Fixed variable name for hint if context.expr is an instance of NameExpr
  • Loading branch information
angelawuuu committed Apr 24, 2024
commit 70d5669410eb1e7b5dfac5deaf8fb9e454e67f45
2 changes: 2 additions & 0 deletions mypy/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,8 @@ def has_no_attr(
if typ_format == '"None"':
if isinstance(context, NameExpr):
var_name = f' {context.name}'
elif isinstance(context.expr, NameExpr):
var_name = f' {context.expr.name}'
elif isinstance(context.expr, MemberExpr):
var_name = f' {get_member_expr_fullname(context.expr)}'
else:
Expand Down
0