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

flake8 2.6.0 breaks ebb-lint #1

Closed
daroot opened this issue Jun 18, 2016 · 3 comments
Closed

flake8 2.6.0 breaks ebb-lint #1

daroot opened this issue Jun 18, 2016 · 3 comments

Comments

@daroot
Copy link

daroot commented Jun 18, 2016

The pep8->pycodestyle change breaks the imports that ebb-lint is using.

Some interaction between flake8 2.6.0 and/or pycodestyle and py.test also breaks all the tests that depend on reading from stdin. I haven't had time to investigate and produce a fix, but the error message on 2.7.11 is as follows.

__________________________________________________________ test_linting_with_stdin_bytes[0] __________________________________________________________

monkeypatch = <_pytest.monkeypatch.monkeypatch instance at 0x1041478c0>, source = ''

    @pytest.mark.parametrize('source', all_sources)
    def test_linting_with_stdin_bytes(monkeypatch, source):
        clean_source, error_locations = find_error_locations(source)
        clean_source_bytes = clean_source.encode('utf-8')
        monkeypatch.setattr(
            pep8, 'stdin_get_value', lambda: clean_source_bytes)
>       assert_ebb_lint(clean_source, 'stdin', error_locations)

.tox/py27/lib/python2.7/site-packages/ebb_lint/test/test_flake8.py:1193:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py27/lib/python2.7/site-packages/ebb_lint/test/test_flake8.py:1159: in assert_ebb_lint
    (line, col, message[:4]) for line, col, message, _ in lint.run()]
.tox/py27/lib/python2.7/site-packages/ebb_lint/flake8.py:269: in run
    self.future_features = detect_future_features(self.source)
.tox/py27/lib/python2.7/site-packages/ebb_lint/flake8.py:240: in source
    pycodestyle.stdin_get_value())
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <_pytest.capture.DontReadFromInput instance at 0x103bcea28>, args = ()

    def read(self, *args):
>       raise IOError("reading from stdin while output is captured")
E       IOError: reading from stdin while output is captured

On python 3.x, the error is similar:

__________________________________________________________ test_linting_with_stdin_text[0] ___________________________________________________________

monkeypatch = <_pytest.monkeypatch.monkeypatch object at 0x106fb6cc0>, source = ''

    @pytest.mark.parametrize('source', all_sources)
    def test_linting_with_stdin_text(monkeypatch, source):
        clean_source, error_locations = find_error_locations(source)
        monkeypatch.setattr(pep8, 'stdin_get_value', lambda: clean_source)
>       assert_ebb_lint(clean_source, 'stdin', error_locations)

.tox/py34/lib/python3.4/site-packages/ebb_lint/test/test_flake8.py:1200:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py34/lib/python3.4/site-packages/ebb_lint/test/test_flake8.py:1159: in assert_ebb_lint
    (line, col, message[:4]) for line, col, message, _ in lint.run()]
.tox/py34/lib/python3.4/site-packages/ebb_lint/test/test_flake8.py:1159: in <listcomp>
    (line, col, message[:4]) for line, col, message, _ in lint.run()]
.tox/py34/lib/python3.4/site-packages/ebb_lint/flake8.py:269: in run
    self.future_features = detect_future_features(self.source)
.tox/py34/lib/python3.4/site-packages/ebb_lint/flake8.py:243: in source
    self._source = pycodestyle.stdin_get_value()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def stdin_get_value():
        """Read the value from stdin."""
>       return TextIOWrapper(sys.stdin.buffer, errors='ignore').read()
E       AttributeError: 'DontReadFromInput' object has no attribute 'buffer'

As a short term fix, pinning to flake8 < 2.6.0 is sufficient, and what I've done locally.

@daroot
Copy link
Author

daroot commented Jun 18, 2016

Okay. I'm dumb. I missed the tests also importing pep8 and monkeypatching it. Once that reference is fixed, using 2.6.0 does not cause problems.

The tests didn't outright fail, because I had a stray legacy pep8 that leaked into my pyenv via a pip.conf.

I'll make the changes in the flowroute repo and you can pull from there if you like.

@habnabit
Copy link
Collaborator

A pull request against this repo would be appreciated if you can.

@daroot
Copy link
Author

daroot commented Jun 27, 2016

Done, PR #3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants