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

Can't read from stdin using flake8-coding and flake8-print at the same time #14

Closed
johnson-christopher opened this issue Aug 7, 2018 · 2 comments · Fixed by #15
Closed

Comments

@johnson-christopher
Copy link
Contributor

Can't use flake8-coding and flake8-print at the same time for emacs flycheck. Unfortunately I don't know if flake8-print or flake8-coding is the issue, but here's the setup. Flycheck attempts to lint my file by running the following command to start flake8 and then feed the file in via stdin:

python -c "import sys,runpy;sys.path.pop(0);runpy.run_module('flake8')" --format=default - < /path/to/my/file.py

The traceback is as follows:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 208, in run_module
    return _run_code(code, {}, init_globals, run_name, mod_spec)
  File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/[scrubbed]/.virtualenvs/transloc/lib/python3.6/site-packages/flake8/__main__.py", line 4, in <module>
    cli.main()
  File "/[scrubbed]/.virtualenvs/transloc/lib/python3.6/site-packages/flake8/main/cli.py", line 16, in main
    app.run(argv)
  File "/[scrubbed]/.virtualenvs/transloc/lib/python3.6/site-packages/flake8/main/application.py", line 396, in run
    self._run(argv)
  File "/[scrubbed]/.virtualenvs/transloc/lib/python3.6/site-packages/flake8/main/application.py", line 384, in _run
    self.run_checks()
  File "/[scrubbed]/.virtualenvs/transloc/lib/python3.6/site-packages/flake8/main/application.py", line 310, in run_checks
    self.file_checker_manager.run()
  File "/[scrubbed]/.virtualenvs/transloc/lib/python3.6/site-packages/flake8/checker.py", line 321, in run
    self.run_serial()
  File "/[scrubbed]/.virtualenvs/transloc/lib/python3.6/site-packages/flake8/checker.py", line 305, in run_serial
    checker.run_checks()
  File "/[scrubbed]/.virtualenvs/transloc/lib/python3.6/site-packages/flake8/checker.py", line 579, in run_checks
    self.run_ast_checks()
  File "/[scrubbed]/.virtualenvs/transloc/lib/python3.6/site-packages/flake8/checker.py", line 493, in run_ast_checks
    for (line_number, offset, text, check) in runner:
  File "/[scrubbed]/.virtualenvs/transloc/lib/python3.6/site-packages/flake8_coding.py", line 53, in run
    lines = self.read_headers()
  File "/[scrubbed]/.virtualenvs/transloc/lib/python3.6/site-packages/flake8_coding.py", line 45, in read_headers
    return pep8.stdin_get_value().splitlines(True)[:2]
  File "/[scrubbed]/.virtualenvs/transloc/lib/python3.6/site-packages/pycodestyle.py", line 1347, in stdin_get_value
    return TextIOWrapper(sys.stdin.buffer, errors='ignore').read()
ValueError: I/O operation on closed file

If I uninstall flake8-coding or flake8-print either one the problem goes away, so I don't know which one is the cause. Trying here first since flake8-coding is the one in the traceback, so I figure if nothing else it's the best place to find out why it crashed, even if it turns out flake8-print is the culprit.

Currently installed versions:

flake8==3.5.0
flake8-coding==1.3.0
flake8-print==3.1.0

@johnson-christopher johnson-christopher changed the title Can't use flake8-coding and flake8-print at the same time. Can't read from stdin using flake8-coding and flake8-print at the same time Aug 7, 2018
@johnson-christopher
Copy link
Contributor Author

I found a possible fix by looking at flake8-commas. It appears using flake8.engine.pep8.stdin_get_value instead of the one from pycodestyle will fix it. PR will be up soon.

@johnson-christopher
Copy link
Contributor Author

@tk0miya Can you look at this PR when you get a chance?

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

Successfully merging a pull request may close this issue.

1 participant