Closed seporaitis closed 4 years ago
Presumably the try/except ImportError
is due to the function moving between different versions of flake8?
If understand correctly this pull request on flake8-commas
the answer is yes.
@JBKahn is there anything I could do to improve this PR so it is easier for you to merge it?
@JBKahn ping
@JBKahn ping
Sorry it took so long but this didn't pass the tests and I had no time to really look at it @nndii . I have to at least ensure tests pass before merging.
In this case, the tests weren't passing with older versions of flake8 that I'm willing to simply stop supporting. Thank you for your patience and thanks for the PR @seporaitis
Summary: Couple of
flake8
plugins rely on pycodestyle.stdin_get_value, which does not cache the string, after reading it from stdin and closing the buffer. This means that if there are two plugins using this function - the second plugin relying on this function, cannot read from stdin, because it was closed, andValueError: I/O operation on closed file
gets raised.Fix: use flake8.utils.stdin_get_value, which caches the stdin, so that multiple plugins can use it. It is based on flake8-commas that does not seem to have this issue.
Steps to reproduce:
requirements.txt
:Run:
Expected output: lint successfully. Actual output:
Additional comments:
In my environment this error got triggered in
flake8-print
andflake8-tuple
. I am simultaneously doing a similar fix toflake8-tuple
as well. However, there must be a third plugin that usespycodestyle.stdin_get_value
first time. I will investigate and do a similar fix as well.I bumped version up as it would be great to release this fix quickly - it would save my eyes from emacs+flycheck blowing up with an error taking half the buffer on every file save. :)
Let me know if I can improve this to expedite the release.
Thank you.