You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importtypingimporturllib.parsedef_parse_dsn(*, dsn, database) ->dict:
ifdsn:
parsed=urllib.parse.urlparse(dsn)
ifparsed.pathanddatabaseisNone:
database=parsed.pathifdatabase.startswith('/'): # this is line 10database=database[1:]
returndict(database=database)
$ mypy test.py fails with:
test.py:10: error: "None" has no attribute "startswith"
test.py:11: error: Value of type "None" is not indexable
despite database provably not being None.
The text was updated successfully, but these errors were encountered:
elprans
changed the title
Incorrect type inference in "if ham and spam is None: foo = ham; foo.startswith('/')"
Incorrect type inference in "if ham and spam is None: spam = ham; spam.startswith('/')"
Dec 4, 2017
Given the following code (test.py):
$ mypy test.py
fails with:despite
database
provably not beingNone
.The text was updated successfully, but these errors were encountered: