Skip to content
Closed
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
added new circumstance of having NONE as the second object of a union…
… with warning message
  • Loading branch information
kr321 authored and kr321 committed Apr 23, 2024
commit 0c28fadd7dccd3c9fdbf3014b42aec1d6f95d3d4
23 changes: 6 additions & 17 deletions mypy/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,23 +522,12 @@ def has_no_attr(
type(item) == NoneType for item in original_type.items
):
typ_format = '"None"'
if typ_format == '"None"':(
self.fail(
'Item {} of {} has no attribute "{}"{}. ADD HINT HERE'.format(
typ_format, orig_type_format, member, extra
),
context,
code=codes.UNION_ATTR,
)
)
else:(
self.fail(
'Item {} of {} has no attribute "{}"{}'.format(
typ_format, orig_type_format, member, extra
),
context,
code=codes.UNION_ATTR,
)
self.fail(
'Item {} of {} has no attribute "{}"{}'.format(
typ_format, orig_type_format, member, extra
),
context,
code=codes.UNION_ATTR,
)
return codes.UNION_ATTR
elif isinstance(original_type, TypeVarType):
Expand Down