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

false positive no-member after isinstance #4168

Closed
kiefermat opened this issue Mar 1, 2021 · 0 comments · Fixed by #4764
Closed

false positive no-member after isinstance #4168

kiefermat opened this issue Mar 1, 2021 · 0 comments · Fixed by #4764
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code
Milestone

Comments

@kiefermat
Copy link

kiefermat commented Mar 1, 2021

Steps to reproduce

Given a file a.py:

# pylint: disable=missing-module-docstring

mixed_tuple = (b"a", b"b", b"c", b"d")
byte_tuple = [arg.encode('utf8') if isinstance(arg, str) else arg for arg in mixed_tuple]

for arg in mixed_tuple:
    if isinstance(arg, str):
        print(arg.encode('utf8'))
    else:
        print(arg)

As soon as the mixed_tuple contains at least one string, the no-member warning is no longer shown.

Current behavior

Result of pylint a.py:

************* Module pixy.a
src/pixy/a.py:4:14: E1101: Instance of 'bytes' has no 'encode' member (no-member)
src/pixy/a.py:8:14: E1101: Instance of 'bytes' has no 'encode' member (no-member)

---------------------------------------------------------------------
Your code has been rated at -6.67/10 (previous run: -15.00/10, +8.33)

Expected behavior

No warning should be shown

pylint --version output

Result of pylint --version output:

pylint 2.7.2
astroid 2.5.1
Python 3.9.1

This behaviour has been introduced with 2.7.0

@Pierre-Sassoulas Pierre-Sassoulas added the False Positive 🦟 A message is emitted but nothing is wrong with the code label Mar 1, 2021
@cdce8p cdce8p added this to the 2.10.0 milestone Aug 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants