aiosmtpd
aiosmtpd copied to clipboard
Fix Session.peer type annotation
What do these changes do?
Updates the type annotation for the Session.peer field.
The annotation was "str or None".
I think the correct annotation should be "tuple[str, int] or None" (more in #518)
Are there changes in behavior for the user?
Type annotation changes should not affect code at runtime.
Dependent code could see new mypy warnings if it also uses the old, now incompatible, type annotation.
Related issue number
Fixes: #518
Checklist
- [x] I think the code is well written
- [ ] Unit tests for the changes exist
- [ ] tox testenvs have been executed in the following environments:
- [x] Linux (Ubuntu 24.04)
{py312} - [ ] 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
- [x] Linux (Ubuntu 24.04)
- [ ] Documentation reflects the changes
- [ ] Add a news fragment into the
NEWS.rstfile
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 97.77%. Comparing base (
f40ac96) to head (91d108b). Report is 41 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #522 +/- ##
==========================================
- Coverage 97.86% 97.77% -0.10%
==========================================
Files 23 23
Lines 5707 5699 -8
Branches 764 764
==========================================
- Hits 5585 5572 -13
- Misses 76 82 +6
+ Partials 46 45 -1
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: 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.
I stumbled into this today. The original code appears to be a misinterpretation of what socket.getpeername() actually returns. As discussed in #518, the type in the PR is correct (for AF_INET4, AF_INET6, or AF_UNIX) and in the AF_UNIX case would contain a str of the socket's filesystem path.
Unfortunately this code change is almost impossible to test without specific network setups, however, arguably it's not this PR's job to test this as the type of the return value of socket.getpeername should be tested in the stdlib and this library should just use the correct type.
So I would vote for accepting the slight lowering of test coverage.
@waynew Anything I can do to help get this merged?