Description
Documentation
Hello, HTTPRedirectHandler
documentation documents some methods take HTTP headers in a parameter named hdrs
:
cpython/Doc/library/urllib.request.rst
Line 896 in c646846
cpython/Doc/library/urllib.request.rst
Line 915 in c646846
cpython/Doc/library/urllib.request.rst
Line 921 in c646846
...
However, the actual implementation uses headers
:
Line 621 in c646846
Line 660 in c646846
Would it be possible to use the same name in the documentation and in the implementation?
Context
In some project, the following class is used to perform HTTPS requests without following redirection:
class NoRedirect(urllib.request.HTTPRedirectHandler):
def redirect_request(
self, req: Any, fp: Any, code: Any, msg: Any, hdrs: Any, newurl: Any
) -> None:
pass
Running a type checker (basedpyright) on this code reports a warning:
error: Method "redirect_request" overrides class "HTTPRedirectHandler" in an incompatible manner
Parameter 6 name mismatch: base parameter is named "headers",
override parameter is named "hdrs" (reportIncompatibleMethodOverride)
This was quite unexpected because the official documentation (https://docs.python.org/3.13/library/urllib.request.html#urllib.request.HTTPRedirectHandler.redirect_request) mentions hdrs
instead of headers
. It makes nonetheless more sense to name the parameter headers
in case callers use the parameter names.
Metadata
Metadata
Assignees
Projects
Status