Skip to content

Resolve all flake8 errors#588

Open
loqs wants to merge 5 commits into
aio-libs:masterfrom
loqs:flake8
Open

Resolve all flake8 errors#588
loqs wants to merge 5 commits into
aio-libs:masterfrom
loqs:flake8

Conversation

@loqs

@loqs loqs commented May 8, 2026

Copy link
Copy Markdown
Contributor

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

  • I think the code is well written
  • [] Unit tests for the changes exist
  • tox testenvs have been executed in the following environments:
    • Linux (Ubuntu 18.04, Ubuntu 20.04, Arch): qa
    • Windows (7, 10): {py36,py37,py38,py39}-{nocov,cov,diffcov}
    • WSL 1.0 (Ubuntu 18.04): {py36,py37,py38,py39}-{nocov,cov,diffcov}, pypy3-{nocov,cov}, qa, docs
    • FreeBSD (12.2, 12.1, 11.4): {py36,pypy3}-{nocov,cov,diffcov}, qa
    • Cygwin: py36-{nocov,cov,diffcov}, qa, docs
  • Documentation reflects the changes
  • Add a news fragment into the NEWS.rst file
    • Add under the "aiosmtpd-next" section, creating one if necessary
      • You may create subsections to group the changes, if you like
    • Use full sentences with correct case and punctuation
    • Refer to relevant Issue if applicable

@codecov

codecov Bot commented May 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.84%. Comparing base (003c265) to head (65d49d9).
⚠️ Report is 2 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread setup.cfg
# 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...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point in the future, it'll be useful to have something like protocols/typed dicts for these.

Comment thread setup.cfg
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" ...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you might be hitting these in top-level pure functions that aren't indented methods under classes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this happening outside of the tests dir?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. Okay. Let's mark them as FIXMEs for now, then.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@loqs by the way, you should have an org invitation in your inbox.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the invitation. I had a minor issue setting up two factor authentication. All sorted now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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" ...?

Comment thread setup.cfg
Comment thread aiosmtpd/tests/test_smtpsmuggling.py Outdated
Comment thread aiosmtpd/tests/test_smtpsmuggling.py Outdated
Comment on lines 1038 to 1047
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)")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Comment thread setup.cfg
loqs added 4 commits July 4, 2026 20:27
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.
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 this pull request may close these issues.

2 participants