diff --git a/mypy/messages.py b/mypy/messages.py index 62846c536f3d..30a8401070c8 100644 --- a/mypy/messages.py +++ b/mypy/messages.py @@ -534,6 +534,12 @@ def has_no_attr( context, code=codes.UNION_ATTR, ) + if typ_format == '"None"': + self.note( + 'You can use "if is not None" check to guard against a None value', + context, + code=codes.UNION_ATTR, + ) return codes.UNION_ATTR elif isinstance(original_type, TypeVarType): bound = get_proper_type(original_type.upper_bound)