fix(resolver): handle None result.service from getnameinfo()#12392
fix(resolver): handle None result.service from getnameinfo()#12392rnagulapalle wants to merge 3 commits intoaio-libs:masterfrom
Conversation
getnameinfo() returns a NameinfoResult where service is typed as str | None. Passing None directly to int() fails mypy's arg-type check. Fall back to the original numeric port when service is None. Fixes mypy error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | ..."
for more information, see https://pre-commit.ci
|
Closing — will be re-raised by Phalanx CI Fixer autonomously. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #12392 +/- ##
==========================================
- Coverage 99.11% 98.92% -0.19%
==========================================
Files 130 134 +4
Lines 45432 46639 +1207
Branches 2400 2429 +29
==========================================
+ Hits 45028 46137 +1109
- Misses 273 373 +100
+ Partials 131 129 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Merging this PR will not alter performance
Comparing Footnotes
|
Summary
getnameinfo()returns aNameinfoResultwhere.serviceis typed asstr | None. The existing code passes it directly toint()which mypy correctly rejects:Fix
Fall back to the original numeric port from the address tuple when
result.serviceisNone:This matches the pattern already used in the non-link-local IPv6 path and the IPv4 path (both use
address[1]directly).Test plan
aiohttp/resolver.pypasses with noarg-typeerrors