yesqa: BUG False positive removal on windows due to IOError
First of all thanks for yet another great tool 😄
Today I was adding pre-commit
(one hook at a time) to an existing codebase and when I added yesqa
, it started having a nasty fight with the flaek8
hook. When I ran pre-commit run --all
on linux (WSL) there was no problem, so I did some digging.
When I started printing the responses from flake8
, I found that all false positive removals returned 0 E902
, which corresponds to an IOError.
I added:
print(filename)
print(line)
to: https://github.com/asottile/yesqa/blob/7a009f3ee493c796827ee334f9058b110a0e0db8/yesqa.py#L25-L30
My guess is that this is due to NamedTemporaryFile
only being partially supported by windows.
https://github.com/asottile/yesqa/blob/7a009f3ee493c796827ee334f9058b110a0e0db8/yesqa.py#L121-L128
My local quick and dirty hotfix for now is adding another check, like the one you use: https://github.com/asottile/yesqa/blob/7a009f3ee493c796827ee334f9058b110a0e0db8/yesqa.py#L130-L132
if any('E902' in v for v in flake8_results.values()):
print(f'{filename}: IO error (skipping)')
return 0
P.S.: Not sure where E999
comes from, but judging by the error message this might be a typo/the error code changed and you might have meant to write E901
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (18 by maintainers)
sounds good, send a patch!
you’ll probably also want to set up CI for windows, you can probably do something similar to what is done for pyupgrade: https://github.com/asottile/pyupgrade/blob/f766c29ec4bb6cf2674b81959871e59d5400380a/azure-pipelines.yml#L17-L20
also you’d use
try: finally:
no need to catch an exception if you were going to approach it that way!BTW, also huge props, I think those are the quickest replies I ever got on any issue.