Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E1133 False positive after isinstance(data, list) #2475

Closed
Gloweye opened this issue Sep 5, 2018 · 2 comments
Closed

E1133 False positive after isinstance(data, list) #2475

Gloweye opened this issue Sep 5, 2018 · 2 comments
Labels
Duplicate 🐫 Duplicate of an already existing issue

Comments

@Gloweye
Copy link

Gloweye commented Sep 5, 2018

Steps to reproduce

def queue(data):
    if data is None:
        data = {"pageSize": 100}
    for key, value in data.items():
        if isinstance(value, list):
            for val in value:
                print(val)

Current behavior

scratches\scratch_14.py:6:23: E1133: Non-iterable value value is used in an iterating context (not-an-iterable)

Expected behavior

Not getting this message after any isinstance(name, list) check, regardless of the data shape before that check.

pylint --version output

pylint 2.1.1
astroid 2.0.4
Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 15 2017, 03:27:45) [MSC v.1900 64 bit (AMD64)]

There's some weird-ass stuff going on here. For example, replacing that key, value in data.items() with a value in data.values() stops this false positive. Of course, the original problem was quite a bit bigger, and I actually use that key. Removing the if self.data is None check+result will remove the warning.

@PCManticore
Copy link
Contributor

Duplicate of #1162. This is a long known problem of pylint as it currently cannot understand control flow primitives. This is somewhat on our roadmap, but not sure when it's going to be implemented per se, but you can check other similar issues https://github.com/PyCQA/pylint/issues?q=is%3Aissue+is%3Aopen+control+flow+label%3Atopic-control-flow.

@PCManticore PCManticore added the Duplicate 🐫 Duplicate of an already existing issue label Sep 6, 2018
@Gloweye
Copy link
Author

Gloweye commented Sep 6, 2018

Even if I'd seen the other one, I probably wouldn't have thought it a dupe. But ok, I'll just add a disable=E1133 to the block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate 🐫 Duplicate of an already existing issue
Projects
None yet
Development

No branches or pull requests

2 participants