-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Control flowRequires control flow understandingRequires control flow understandingMinor 💅Polishing pylint is always nicePolishing pylint is always nice
Description
Steps to reproduce
def subscriptable(flag):
state = None
for _ in [0, 1]:
if state is None:
if flag:
state = [None]
elif state[0] is None:
print('subscripted')
Current behavior
E: 7,13: Value 'state' is unsubscriptable (unsubscriptable-object)
Expected behavior
state is subscriptable by the time it gets subscripted, so that
error is wrong. After all, the code runs:
>>> subscriptable(False)
>>> subscriptable(True)
subscripted
That said, it does look like it could be an error, or maybe it would
be an error in a more complicated case, so maybe a warning could be
emitted -- possibly-unsubscriptable-object or something like that.
Related to, but more specific than, #701
pylint --version output
pylint 2.0.0
astroid 2.0.0
Python 3.6.5 (default, Mar 30 2018, 06:42:10)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)]
Metadata
Metadata
Assignees
Labels
Control flowRequires control flow understandingRequires control flow understandingMinor 💅Polishing pylint is always nicePolishing pylint is always nice