-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Description
The error message you get when something is Optional and you try to access it isn't as friendly as it might be (with --strict-optional). Eg if I have
def foo(s: Optional[str]) -> None:
print(s.count('a'))
It says error: Some element of union has no attribute "count".
It would be nicer if it said something like Variable 's' may be None or something a bit special cased to the Union with None case.
Generalizing a bit, one could imagine better handling of Unions in general by specifying what is in the Union or even which types in the Unions are causing the issue.
Reactions are currently unavailable