-
-
Notifications
You must be signed in to change notification settings - Fork 322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove incorrect str
possibility from HostnameResolver.getaddrinfo
#2964
Conversation
`_socket.getaddrinfo` takes care of encoding all passed in `str` host arguments before passing it to a custom resolver. Additionally, the docs say that a resolver will always receive IDNA-encoded bytes. However, the type hints of `HostnameResolver.getaddrinfo` imply that a resolver may need to contend with a `str` Remove the extraneous appearance
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2964 +/- ##
=======================================
Coverage 99.64% 99.64%
=======================================
Files 117 117
Lines 17634 17634
Branches 3172 3172
=======================================
Hits 17572 17572
Misses 43 43
Partials 19 19
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this assessment. For others who want to double check:
Lines 223 to 230 in accaae4
if isinstance(host, str): | |
try: | |
host = host.encode("ascii") | |
except UnicodeEncodeError: | |
# UTS-46 defines various normalizations; in particular, by default | |
# idna.encode will error out if the hostname has Capital Letters | |
# in it; with uts46=True it will lowercase them instead. | |
host = _idna.encode(host, uts46=True) |
... I was going to ask about putting @typing.override
on these implementations of HostnameResolver
but turns out that doesn't warn on the signatures being different! So nevermind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty straightforward, seems correct.
thanks! Surprised there haven't been more typing errors that snuck through. |
Type checker must be working well! |
Thanks everyone! I realize I forgot a changelog entry. Does this warrant one, or is it too small to care? |
I guess it technically is a public-facing change, but I think it's probably too small to care. |
_socket.getaddrinfo
takes care of encoding all passed instr
host arguments before passing it to a custom resolver. Additionally, the docs say that a resolver will always receive IDNA-encoded bytes.However, the type hints of
HostnameResolver.getaddrinfo
imply that a resolver may need to contend with astr
Remove the extraneous appearance