Skip to content

Conversation

@cuu508
Copy link
Contributor

@cuu508 cuu508 commented Oct 28, 2024

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

  • I think the code is well written
  • Unit tests for the changes exist
  • tox testenvs have been executed in the following environments:
    • 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
  • Documentation reflects the changes
  • Add a news fragment into the NEWS.rst file

@cuu508 cuu508 marked this pull request as draft October 28, 2024 09:04
@codecov
Copy link

codecov bot commented Oct 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

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     

☔ View full report in Codecov by Sentry.
📢 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.

@cuu508 cuu508 marked this pull request as ready for review October 28, 2024 10:10
@jdelic
Copy link

jdelic commented Jul 15, 2025

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?

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.

Incorrect type annotation for Session.peer

2 participants