overzealous removal of noqa: E402
See original GitHub issueGiven this setup
$ cat .pre-commit-config.yaml
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.0.0
hooks:
- id: flake8
additional_dependencies:
- flake8==3.6.0
- repo: https://github.com/asottile/yesqa
rev: v0.0.8
hooks:
- id: yesqa
additional_dependencies:
- flake8==3.6.0
$ cat example.py
import gevent.monkey
gevent.monkey.patch_all()
from datetime import datetime
print(gevent.spawn(lambda: datetime.now()).get())
Then pre-commit run flake8 --files example.py
fails with
Flake8...................................................................Failed
hookid: flake8
example.py:4:1: E402 module level import not at top of file
This is expected. However if I change line 2 (not the reported line 4) to be:
- gevent.monkey.patch_all()
+ gevent.monkey.patch_all() # noqa: E402
Then flake8
passes, but yesqa
will rewrite the file and remove the noqa
, causing flake8
to fail again.
Should yesqa
instead keep that noqa
? Or should I noqa: E402
line 4 and any other possible imports I add in the future?
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
What does '# noqa' mean in Python comments? - Stack Overflow
noqa most likely stands for no quality assurance . It tells code-analysis software to ignore warnings. – Stevoisiak. Jan 30, 2018 at 17:23....
Read more >Text - Python mailing list
+ """ > + match = not noqa and COMPARE_SINGLETON_REGEX.search(logical_line) > + if match: ... + > + The older syntax is removed...
Read more >OpenStack: ChangeLog - Fossies
As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers.
Read more >app-admin - Gentoo
-rw-r--r--, app-admin/elektra/files/elektra-0.7.1-remove-ddefault-link.patch, 16 ... +-# flake8: noqa: E402. +-from ansible.module_utils.common.yaml import ...
Read more >将源码从旧仓库迁移到新仓库中 · db10ea6e93 - 代码服务器
+ URLs, and so have had parameters added. This was removed in v2.12.2 in an. + overzealous attempt to resolve problems with IDNA-encoding...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
flake8 3.8 has been released so the behaviour here is now consistent
probably add special casing in yesqa for E402. The eventual long-term northstar is to make flake8 error on
noqa
that doesn’t apply but I think that’s pretty far off