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

Incorrect "unsupported-membership-test" error on subprocess.check_output #689

Closed
ncoghlan opened this issue Aug 25, 2019 · 1 comment
Closed
Labels
Brain 🧠 Needs a brain tip Bug 🪳 Good first issue Friendly and approachable by new contributors

Comments

@ncoghlan
Copy link

ncoghlan commented Aug 25, 2019

(Migrating from pylint-dev/pylint#3045 (comment))

Steps to reproduce

  1. Perform a substring check on the result of subprocess.check_output

Current behavior

pylint reports E1135 (unsupported-membership-test)

Expected behavior

pylint allows the operation (since both bytes and strings support containment checks, and those are the two possible return types from check_output)

Software version

The error was found on Debian 9 with pylint 2.3.1, astroid 2.2.5, and Python 3.5.3.

Additional info

import subprocess

bytes_data = subprocess.check_output(['echo', 'hello']);
text_data = subprocess.check_output(['echo', 'hello'], universal_newlines=True);

print(b'bytes' in bytes_data) # Prints False
print('text' in text_data)    # Prints False
'text' in bytes_data   # Runtime TypeError
b'bytes' in text_data  # Runtime TypeError
$ pylint -E check_pylint_e1135.py
************* Module check_pylint_e1135
check_pylint_e1135.py:6:18: E1135: Value 'bytes_data' doesn't support membership test (unsupported-membership-test)
check_pylint_e1135.py:7:16: E1135: Value 'text_data' doesn't support membership test (unsupported-membership-test)
check_pylint_e1135.py:8:10: E1135: Value 'bytes_data' doesn't support membership test (unsupported-membership-test)
check_pylint_e1135.py:9:12: E1135: Value 'text_data' doesn't support membership test (unsupported-membership-test)
@ncoghlan ncoghlan changed the title Incorrect "unsupported-membership-test" warning on subprocess.check-output Incorrect "unsupported-membership-test" warning on subprocess.check_output Aug 25, 2019
@ncoghlan ncoghlan changed the title Incorrect "unsupported-membership-test" warning on subprocess.check_output Incorrect "unsupported-membership-test" error on subprocess.check_output Aug 25, 2019
@PCManticore PCManticore added Brain 🧠 Needs a brain tip Bug 🪳 Good first issue Friendly and approachable by new contributors labels Sep 8, 2019
@ncoghlan
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Brain 🧠 Needs a brain tip Bug 🪳 Good first issue Friendly and approachable by new contributors
Projects
None yet
Development

No branches or pull requests

2 participants