Resolve all flake8 errors#588
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #588 +/- ##
==========================================
+ Coverage 97.81% 97.84% +0.03%
==========================================
Files 23 23
Lines 5714 5715 +1
Branches 352 352
==========================================
+ Hits 5589 5592 +3
+ Misses 75 73 -2
Partials 50 50 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| # I still can't grok the need to annotate "self" or "cls" ... | ||
| ANN101 | ||
| ANN102 | ||
| # I don't think forcing annotation for *args and **kwargs is a wise idea... |
There was a problem hiding this comment.
At some point in the future, it'll be useful to have something like protocols/typed dicts for these.
| PT004 | ||
| # Sometimes exception needs to be explicitly raised in special circumstances, needing additional lines of code | ||
| PT012 | ||
| # I still can't grok the need to annotate "self" or "cls" ... |
There was a problem hiding this comment.
I think you might be hitting these in top-level pure functions that aren't indented methods under classes.
There was a problem hiding this comment.
Is this happening outside of the tests dir?
There was a problem hiding this comment.
Yes:
flake8 --isolated --select ANN101 aiosmtpd
aiosmtpd/controller.py:99:18: ANN101 Missing type annotation for self in method
aiosmtpd/controller.py:106:25: ANN101 Missing type annotation for self in method
aiosmtpd/controller.py:118:9: ANN101 Missing type annotation for self in method
aiosmtpd/controller.py:152:17: ANN101 Missing type annotation for self in method
aiosmtpd/controller.py:156:26: ANN101 Missing type annotation for self in method
aiosmtpd/controller.py:170:24: ANN101 Missing type annotation for self in method
aiosmtpd/controller.py:176:18: ANN101 Missing type annotation for self in method
aiosmtpd/controller.py:184:22: ANN101 Missing type annotation for self in method
aiosmtpd/controller.py:201:9: ANN101 Missing type annotation for self in method
aiosmtpd/controller.py:223:25: ANN101 Missing type annotation for self in method
aiosmtpd/controller.py:229:14: ANN101 Missing type annotation for self in method
aiosmtpd/controller.py:254:15: ANN101 Missing type annotation for self in method
aiosmtpd/controller.py:305:14: ANN101 Missing type annotation for self in method
aiosmtpd/controller.py:320:9: ANN101 Missing type annotation for self in method
aiosmtpd/controller.py:338:15: ANN101 Missing type annotation for self in method
aiosmtpd/controller.py:347:24: ANN101 Missing type annotation for self in method
aiosmtpd/controller.py:365:13: ANN101 Missing type annotation for self in method
aiosmtpd/controller.py:383:9: ANN101 Missing type annotation for self in method
aiosmtpd/controller.py:399:24: ANN101 Missing type annotation for self in method
aiosmtpd/controller.py:412:25: ANN101 Missing type annotation for self in method
aiosmtpd/controller.py:432:9: ANN101 Missing type annotation for self in method
aiosmtpd/controller.py:445:24: ANN101 Missing type annotation for self in method
aiosmtpd/controller.py:471:25: ANN101 Missing type annotation for self in method
aiosmtpd/controller.py:490:25: ANN101 Missing type annotation for self in method
aiosmtpd/controller.py:502:25: ANN101 Missing type annotation for self in method
aiosmtpd/docs/_exts/autoprogramm.py:204:18: ANN101 Missing type annotation for self in method
aiosmtpd/docs/_exts/autoprogramm.py:287:13: ANN101 Missing type annotation for self in method
aiosmtpd/handlers.py:58:18: ANN101 Missing type annotation for self in method
aiosmtpd/handlers.py:80:32: ANN101 Missing type annotation for self in method
aiosmtpd/handlers.py:93:9: ANN101 Missing type annotation for self in method
aiosmtpd/handlers.py:118:18: ANN101 Missing type annotation for self in method
aiosmtpd/handlers.py:123:9: ANN101 Missing type annotation for self in method
aiosmtpd/handlers.py:150:9: ANN101 Missing type annotation for self in method
aiosmtpd/handlers.py:188:18: ANN101 Missing type annotation for self in method
aiosmtpd/handlers.py:192:9: ANN101 Missing type annotation for self in method
aiosmtpd/handlers.py:212:9: ANN101 Missing type annotation for self in method
aiosmtpd/handlers.py:220:9: ANN101 Missing type annotation for self in method
aiosmtpd/handlers.py:227:24: ANN101 Missing type annotation for self in method
aiosmtpd/handlers.py:234:9: ANN101 Missing type annotation for self in method
aiosmtpd/handlers.py:243:9: ANN101 Missing type annotation for self in method
aiosmtpd/handlers.py:250:30: ANN101 Missing type annotation for self in method
aiosmtpd/handlers.py:257:9: ANN101 Missing type annotation for self in method
aiosmtpd/handlers.py:265:24: ANN101 Missing type annotation for self in method
aiosmtpd/handlers.py:268:15: ANN101 Missing type annotation for self in method
aiosmtpd/lmtp.py:14:25: ANN101 Missing type annotation for self in method
aiosmtpd/lmtp.py:18:25: ANN101 Missing type annotation for self in method
aiosmtpd/lmtp.py:22:25: ANN101 Missing type annotation for self in method
aiosmtpd/proxy_protocol.py:99:20: ANN101 Missing type annotation for self in method
aiosmtpd/proxy_protocol.py:102:27: ANN101 Missing type annotation for self in method
aiosmtpd/proxy_protocol.py:105:25: ANN101 Missing type annotation for self in method
aiosmtpd/proxy_protocol.py:136:18: ANN101 Missing type annotation for self in method
aiosmtpd/proxy_protocol.py:140:21: ANN101 Missing type annotation for self in method
aiosmtpd/proxy_protocol.py:143:22: ANN101 Missing type annotation for self in method
aiosmtpd/proxy_protocol.py:291:15: ANN101 Missing type annotation for self in method
aiosmtpd/proxy_protocol.py:295:13: ANN101 Missing type annotation for self in method
aiosmtpd/proxy_protocol.py:301:20: ANN101 Missing type annotation for self in method
aiosmtpd/proxy_protocol.py:316:22: ANN101 Missing type annotation for self in method
aiosmtpd/proxy_protocol.py:331:18: ANN101 Missing type annotation for self in method
aiosmtpd/qa/test_0packaging.py:29:21: ANN101 Missing type annotation for self in method
aiosmtpd/qa/test_0packaging.py:37:9: ANN101 Missing type annotation for self in method
aiosmtpd/qa/test_0packaging.py:59:27: ANN101 Missing type annotation for self in method
aiosmtpd/qa/test_0packaging.py:81:27: ANN101 Missing type annotation for self in method
aiosmtpd/qa/test_1testsuite.py:38:23: ANN101 Missing type annotation for self in method
aiosmtpd/qa/test_1testsuite.py:43:22: ANN101 Missing type annotation for self in method
aiosmtpd/qa/test_1testsuite.py:48:23: ANN101 Missing type annotation for self in method
aiosmtpd/qa/test_1testsuite.py:73:23: ANN101 Missing type annotation for self in method
aiosmtpd/qa/test_1testsuite.py:89:26: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:150:17: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:153:18: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:159:18: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:182:20: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:190:20: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:199:18: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:317:13: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:465:25: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:468:26: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:471:34: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:479:32: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:485:17: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:497:25: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:530:25: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:547:22: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:559:24: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:566:21: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:577:13: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:584:30: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:588:25: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:592:20: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:604:32: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:615:30: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:797:33: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:810:33: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:826:25: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:840:25: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:890:25: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:895:25: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:907:29: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:945:25: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:1023:9: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:1073:13: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:1086:23: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:1124:26: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:1149:26: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:1173:32: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:1179:18: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:1189:27: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:1209:13: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:1222:27: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:1230:25: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:1254:25: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:1271:25: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:1344:25: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:1397:25: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:1410:25: ANN101 Missing type annotation for self in method
aiosmtpd/smtp.py:1545:25: ANN101 Missing type annotation for self in method
....results in test directory removed
flake8 --isolated --select ANN102 aiosmtpd
aiosmtpd/proxy_protocol.py:167:9: ANN102 Missing type annotation for cls in classmethod
aiosmtpd/proxy_protocol.py:221:9: ANN102 Missing type annotation for cls in classmethod
aiosmtpd/proxy_protocol.py:236:21: ANN102 Missing type annotation for cls in classmethod
....results in test directory removed
There was a problem hiding this comment.
Ah. Okay. Let's mark them as FIXMEs for now, then.
There was a problem hiding this comment.
@loqs by the way, you should have an org invitation in your inbox.
There was a problem hiding this comment.
Thanks for the invitation. I had a minor issue setting up two factor authentication. All sorted now.
There was a problem hiding this comment.
Ah. Okay. Let's mark them as FIXMEs for now, then.
Should I remove the restored comment # I still can't grok the need to annotate "self" or "cls" ...?
| if (mechanism, init_resp) == ("login", False) and ( | ||
| (3, 9, 0) < sys.version_info < (3, 9, 4)): | ||
| (3, 9, 0) < sys.version_info < (3, 9, 4) | ||
| ): | ||
| # The bug with SMTP.auth_login was fixed in Python 3.10 and backported | ||
| # to 3.9.4 | ||
| # See https://github.com/python/cpython/pull/24118 for the fixes.: | ||
| with pytest.raises(SMTPAuthenticationError): | ||
| client.auth(mechanism, auth_meth, initial_response_ok=init_resp) | ||
| client.docmd("*") | ||
| pytest.xfail(reason="smtplib.SMTP.auth_login is buggy (bpo-27820)") |
There was a problem hiding this comment.
I'm wondering if things like this could be dropped soon. Especially since Python 3.9 is EOL and 3.10 will be in a couple of months. I bet nobody's running tests on these patch versions anyway.
Of course, this isn't something in the scope of this PR. Just putting it out there that we should work on reworking the support matrix (CI and packaging metadata) to only deal with >= 3.10 (and >= 3.11 in the fall).
These were removed in commit 8d81f96. This reduces the number of flake8 errors from 1775 to 4. Global ignores: ANN002: Missing type annotation for *args ANN003: Missing type annotation for **kwargs ANN101: Missing type annotation for self in method ANN102: Missing type annotation for cls in classmethod Fixed per-file-ignores: aiosmtpd/tests/test_*:ANN001 Related settings: min-coverage-percents = 12 suppress-none-returning = True suppress-dummy-args = True allow-untyped-defs = True
Global name is declared but never assigned to within that scope. Fix by removing unnecessary 'nonlocal thread' declarations in test_server.py.
Use of pytest.warns() without a match parameter. Add match parameter to pytest.warns for specificity.
Multiline container is not broken after opening character. Fix by adding line break.
aiosmtpd/tests/test_smtpsmuggling.py:0:1: TAE001 too few type annotations (0%). Add type annotations to aiosmtpd/tests/test_smtpsmuggling.py.
What do these changes do?
Restore flake8 related settings removed in commit 8d81f96 reducing the number of flake8 errors from 1775 to 4. The remaining 4 flake8 errors are each fixed in their own commit.
Are there changes in behavior for the user?
No.
Related issue number
Related #544.
Checklist
qa{py36,py37,py38,py39}-{nocov,cov,diffcov}{py36,py37,py38,py39}-{nocov,cov,diffcov}, pypy3-{nocov,cov}, qa, docs{py36,pypy3}-{nocov,cov,diffcov}, qapy36-{nocov,cov,diffcov}, qa, docsNEWS.rstfile