httpx
httpx copied to clipboard
Add type parameters to generics in Client
The public API is now "fully typed" with generous use of Any
. I have ideas of how to get rid of those but wanted to limit the scope of this PR.
- Initially raised as discussion #2181
Notable Changes
- Added
[..., typing.Any]
to all Callables in_client.py
pending narrower typing. - Typed
RequestData
type alias asDict[Any, Any]
.
Hiya - thanks for getting involved!
From my perspective there's too many different sets of changes in this pull request at one time. It'd be easier to work through smaller sets of changes, each only addressing one set of related type changes at a time.
For example, I'd want to work through event hooks as one isolated PR. extensions as one isolated PR. etc.
Some of these we might want, some we might not, and and some we might want to adapt.
Sounds good! I'll split up the PR and try to be more granular. I can see I got a little carried away there.
Updated PR to narrow the scope.
This is a bit surprising to me, as I don't see there's any semantic difference between e.g. dict
and Dict[Any, Any]
-- those are the same thing, right?
Is pyright's "need explicit Any" okay to comply with here?
We've got similar "typing strictness" questions in the past where users use strict settings and tools then expect all libraries to comply.
Ideally that would only be configured on user code.
The way I understand it dict
and Dict[Any, Any]
are not quite the same semantically. The former says "I don't know/care what types this dict holds" and the latter says "I'll deal with types of this dict at runtime".
Although having to add # type: ignore
wherever you use httpx
is no fun, this PR isn't so much about complying with "no implicit any" but more about gradually moving toward stronger typing.
On the note of applying strict to library code, users turn on strict to achieve a certain level of type safety and should be made aware if they're using a library that doesn't align with those goals. If anything, when using strict, one's dependencies should probably be more type-safe than their own code as the effort required to fix any errors/unexpected behaviors is much larger there. There is also an added benefit to users that don't care about type safety is ergonomics (autocomplete, method parameter hints, etc.).
Okay, so our baseline for typing changes like this should be… does this improve the tooling situation for our users. I’ve not been able to install pyright
successfully on my desktop. I’ll have another look into that sometime, but for now…
- Is anyone able to run
pyright --verifytypes httpx
and show what output that currently displays? - Is anyone able to show us an screenshot example of VSCode having an issue with the
httpx
public interface?
Ideally we’d have any checks here integrated into our tooling. I don’t know if there are any mypy
options that’d get us close enough to pyright’s different expectations. We could also consider adding pyright
checking to our CI scripts. Although failing to be able to pip install pyright
and end up with a working installation is being a bit of a blocker from what I can see.
I’ve not been able to install pyright successfully on my desktop
I recommend using npm
: npm install -g pyright
Okay, so our baseline for typing changes like this should be… does this improve the tooling situation for our users.
Yep agreed. And I think "does our public API pass Pyright in strict mode" is the bar to meet (not that we have to fully type anything, we can always use Any
but foo: dict
for example won't cut it).
- Is anyone able to run
pyright --verifytypes httpx
and show what output that currently displays?
Results
Module name: "httpx"
Package directory: "httpx/httpx"
Module directory: "httpx/httpx"
Path of py.typed file: "httpx/httpx/py.typed"
Public modules: 2
httpx
httpx.__version__
Symbols used in public interface:
httpx.__description__
httpx/httpx/__version__.py: error: Type is missing type annotation and could be inferred differently by type checkers
Inferred type is "Literal['A next generation HTTP client, for Python 3.']"
httpx.delete
httpx/httpx/_api.py: error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_api.py: error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_api.py: error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_api.py: error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | None"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx/httpx/_api.py: error: Type of parameter "proxies" is partially unknown
Parameter type is "ProxiesTypes | None"
httpx/httpx/_api.py: error: Return type is partially unknown
Return type is "Response"
httpx._urls.URL.params
httpx/httpx/_urls.py: error: Return type is partially unknown
Return type is "QueryParams"
httpx._urls.QueryParams.keys
httpx/httpx/_urls.py:573:9 - error: Return type is partially unknown
Return type is "KeysView[Unknown]"
Type argument 1 for class "KeysView" has unknown type
httpx._urls.QueryParams.values
httpx/httpx/_urls.py:584:9 - error: Return type is partially unknown
Return type is "ValuesView[Unknown]"
Type argument 1 for class "ValuesView" has unknown type
httpx._urls.QueryParams.items
httpx/httpx/_urls.py:596:9 - error: Return type is partially unknown
Return type is "ItemsView[Unknown, Unknown]"
Type argument 1 for class "ItemsView" has unknown type
Type argument 2 for class "ItemsView" has unknown type
httpx._urls.URL.copy_merge_params
httpx/httpx/_urls.py:474:9 - error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes"
httpx._models.Cookies
error: Type of base class "typing.MutableMapping" is partially unknown
Type argument 1 for class "MutableMapping" has unknown type
Type argument 2 for class "MutableMapping" has unknown type
httpx._models.Cookies.extract_cookies
httpx/httpx/_models.py:1027:9 - error: Type of parameter "response" is partially unknown
Parameter type is "Response"
httpx._models.Response.__init__
httpx/httpx/_models.py:446:9 - error: Type of parameter "request" is partially unknown
Parameter type is "Request | None"
httpx._models.Request.__init__
httpx/httpx/_models.py:308:9 - error: Type of parameter "url" is partially unknown
Parameter type is "URL | str"
httpx/httpx/_models.py:308:9 - error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx._models.Request.method
httpx/httpx/_models.py:323:14 - error: Type is missing type annotation and could be inferred differently by type checkers
Inferred type is "str"
httpx._models.Request.url
httpx/httpx/_models.py:330:18 - error: Type is missing type annotation and could be inferred differently by type checkers
Inferred type is "URL"
httpx._models.Request.headers
httpx/httpx/_models.py:390:14 - error: Type is missing type annotation and could be inferred differently by type checkers
Inferred type is "Headers"
httpx._models.Request.extensions
httpx/httpx/_models.py:441:14 - error: Type is missing type annotation and could be inferred differently by type checkers
Inferred type is "RequestExtensions"
httpx._models.Request.stream
httpx/httpx/_models.py:442:14 - error: Type is missing type annotation and could be inferred differently by type checkers
Inferred type is "ByteStream"
httpx/httpx/_models.py:442:14 - error: Type is missing type annotation and could be inferred differently by type checkers
Inferred type is "UnattachedStream"
httpx._models.Response.request
httpx/httpx/_models.py: error: Return type is partially unknown
Return type is "Request"
httpx/httpx/_models.py: error: Type of parameter "value" is partially unknown
Parameter type is "Request"
httpx._models.Response.url
httpx/httpx/_models.py: error: Return type is partially unknown
Return type is "URL"
httpx._models.Response.headers
httpx/httpx/_models.py:462:14 - error: Type is missing type annotation and could be inferred differently by type checkers
Inferred type is "Headers"
httpx._models.Response.extensions
httpx/httpx/_models.py:793:14 - error: Type is missing type annotation and could be inferred differently by type checkers
Inferred type is "ResponseExtensions"
httpx._models.Response.history
httpx/httpx/_models.py:471:14 - error: Type is missing type annotation and could be inferred differently by type checkers
Inferred type is "list[Response]"
httpx._models.Response.is_closed
httpx/httpx/_models.py:1000:18 - error: Type is missing type annotation and could be inferred differently by type checkers
Inferred type is "bool"
httpx._models.Response.is_stream_consumed
httpx/httpx/_models.py:976:14 - error: Type is missing type annotation and could be inferred differently by type checkers
Inferred type is "bool"
httpx._models.Response.stream
httpx/httpx/_models.py:794:14 - error: Type is missing type annotation and could be inferred differently by type checkers
Inferred type is "UnattachedStream"
httpx._models.Cookies.set_cookie_header
httpx/httpx/_models.py:1036:9 - error: Type of parameter "request" is partially unknown
Parameter type is "Request"
httpx._models.Cookies.jar
httpx/httpx/_models.py:1025:18 - error: Type is missing type annotation and could be inferred differently by type checkers
Inferred type is "CookieJar"
httpx._auth.Auth.auth_flow
httpx/httpx/_auth.py:30:9 - error: Type of parameter "request" is partially unknown
Parameter type is "Request"
httpx._auth.Auth.sync_auth_flow
httpx/httpx/_auth.py:54:9 - error: Type of parameter "request" is partially unknown
Parameter type is "Request"
httpx._auth.Auth.async_auth_flow
httpx/httpx/_auth.py:79:15 - error: Type of parameter "request" is partially unknown
Parameter type is "Request"
httpx._config.Proxy.__init__
httpx/httpx/_config.py:319:9 - error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx.get
httpx/httpx/_api.py: error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_api.py: error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_api.py: error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_api.py: error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | None"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx/httpx/_api.py: error: Type of parameter "proxies" is partially unknown
Parameter type is "ProxiesTypes | None"
httpx/httpx/_api.py: error: Return type is partially unknown
Return type is "Response"
httpx.head
httpx/httpx/_api.py: error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_api.py: error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_api.py: error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_api.py: error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | None"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx/httpx/_api.py: error: Type of parameter "proxies" is partially unknown
Parameter type is "ProxiesTypes | None"
httpx/httpx/_api.py: error: Return type is partially unknown
Return type is "Response"
httpx.options
httpx/httpx/_api.py: error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_api.py: error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_api.py: error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_api.py: error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | None"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx/httpx/_api.py: error: Type of parameter "proxies" is partially unknown
Parameter type is "ProxiesTypes | None"
httpx/httpx/_api.py: error: Return type is partially unknown
Return type is "Response"
httpx.patch
httpx/httpx/_api.py: error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_api.py: error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_api.py: error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_api.py: error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | None"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx/httpx/_api.py: error: Type of parameter "proxies" is partially unknown
Parameter type is "ProxiesTypes | None"
httpx/httpx/_api.py: error: Return type is partially unknown
Return type is "Response"
httpx.post
httpx/httpx/_api.py: error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_api.py: error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_api.py: error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_api.py: error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | None"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx/httpx/_api.py: error: Type of parameter "proxies" is partially unknown
Parameter type is "ProxiesTypes | None"
httpx/httpx/_api.py: error: Return type is partially unknown
Return type is "Response"
httpx.put
httpx/httpx/_api.py: error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_api.py: error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_api.py: error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_api.py: error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | None"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx/httpx/_api.py: error: Type of parameter "proxies" is partially unknown
Parameter type is "ProxiesTypes | None"
httpx/httpx/_api.py: error: Return type is partially unknown
Return type is "Response"
httpx.request
httpx/httpx/_api.py: error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_api.py: error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_api.py: error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_api.py: error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | None"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx/httpx/_api.py: error: Type of parameter "proxies" is partially unknown
Parameter type is "ProxiesTypes | None"
httpx/httpx/_api.py: error: Return type is partially unknown
Return type is "Response"
httpx.stream
httpx/httpx/_api.py: error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_api.py: error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_api.py: error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_api.py: error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | None"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx/httpx/_api.py: error: Type of parameter "proxies" is partially unknown
Parameter type is "ProxiesTypes | None"
httpx._auth.BasicAuth
error: Type of base class "httpx._auth.Auth" is partially unknown
httpx._auth.BasicAuth.auth_flow
httpx/httpx/_auth.py:129:9 - error: Type of parameter "request" is partially unknown
Parameter type is "Request"
httpx._auth.DigestAuth
error: Type of base class "httpx._auth.Auth" is partially unknown
httpx._auth.DigestAuth.auth_flow
httpx/httpx/_auth.py:159:9 - error: Type of parameter "request" is partially unknown
Parameter type is "Request"
httpx._client.AsyncClient
error: Type of base class "httpx._client.BaseClient" is partially unknown
httpx._client.AsyncClient.__init__
httpx/httpx/_client.py:1345:9 - error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | None"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx/httpx/_client.py:1345:9 - error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_client.py:1345:9 - error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_client.py:1345:9 - error: Type of parameter "proxies" is partially unknown
Parameter type is "ProxiesTypes | None"
httpx/httpx/_client.py:1345:9 - error: Type of parameter "event_hooks" is partially unknown
Parameter type is "Mapping[str, List[(...) -> Unknown]] | None"
Type argument 2 for class "Mapping" has partially unknown type
httpx/httpx/_client.py:1345:9 - error: Type of parameter "base_url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_client.py:1345:9 - error: Type of parameter "transport" is partially unknown
Parameter type is "AsyncBaseTransport | None"
httpx/httpx/_client.py:1345:9 - error: Type of parameter "app" is partially unknown
Parameter type is "((...) -> Unknown) | None"
Type annotation for parameter "args" is missing
Type annotation for parameter "kwargs" is missing
httpx._transports.base.AsyncBaseTransport.handle_async_request
httpx/httpx/_transports/base.py:73:15 - error: Type of parameter "request" is partially unknown
Parameter type is "Request"
httpx._client.AsyncClient.request
httpx/httpx/_client.py:1484:15 - error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_client.py:1484:15 - error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_client.py:1484:15 - error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_client.py:1484:15 - error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | UseClientDefault | None"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx._client.AsyncClient.stream
httpx/httpx/_client.py:1533:15 - error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_client.py:1533:15 - error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_client.py:1533:15 - error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_client.py:1533:15 - error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | UseClientDefault"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx._client.AsyncClient.send
httpx/httpx/_client.py:1584:15 - error: Type of parameter "request" is partially unknown
Parameter type is "Request"
httpx/httpx/_client.py:1584:15 - error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | UseClientDefault | None"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx._client.AsyncClient.get
httpx/httpx/_client.py:1737:15 - error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_client.py:1737:15 - error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_client.py:1737:15 - error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_client.py:1737:15 - error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | UseClientDefault | None"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx._client.AsyncClient.options
httpx/httpx/_client.py:1766:15 - error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_client.py:1766:15 - error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_client.py:1766:15 - error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_client.py:1766:15 - error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | UseClientDefault"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx._client.AsyncClient.head
httpx/httpx/_client.py:1795:15 - error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_client.py:1795:15 - error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_client.py:1795:15 - error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_client.py:1795:15 - error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | UseClientDefault"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx._client.AsyncClient.post
httpx/httpx/_client.py:1824:15 - error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_client.py:1824:15 - error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_client.py:1824:15 - error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_client.py:1824:15 - error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | UseClientDefault"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx._client.AsyncClient.put
httpx/httpx/_client.py:1861:15 - error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_client.py:1861:15 - error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_client.py:1861:15 - error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_client.py:1861:15 - error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | UseClientDefault"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx._client.AsyncClient.patch
httpx/httpx/_client.py:1898:15 - error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_client.py:1898:15 - error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_client.py:1898:15 - error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_client.py:1898:15 - error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | UseClientDefault"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx._client.AsyncClient.delete
httpx/httpx/_client.py:1935:15 - error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_client.py:1935:15 - error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_client.py:1935:15 - error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_client.py:1935:15 - error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | UseClientDefault"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx._client.BaseClient.__init__
httpx/httpx/_client.py:157:9 - error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | None"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx/httpx/_client.py:157:9 - error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_client.py:157:9 - error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_client.py:157:9 - error: Type of parameter "event_hooks" is partially unknown
Parameter type is "Mapping[str, List[(...) -> Unknown]] | None"
Type argument 2 for class "Mapping" has partially unknown type
httpx/httpx/_client.py:157:9 - error: Type of parameter "base_url" is partially unknown
Parameter type is "URLTypes"
httpx._client.BaseClient.event_hooks
httpx/httpx/_client.py: error: Return type is partially unknown
Return type is "Dict[str, List[(...) -> Unknown]]"
Type argument 2 for class "dict" has partially unknown type
httpx/httpx/_client.py: error: Type of parameter "event_hooks" is partially unknown
Parameter type is "Dict[str, List[(...) -> Unknown]]"
Type argument 2 for class "dict" has partially unknown type
httpx._client.BaseClient.auth
httpx/httpx/_client.py: error: Return type is partially unknown
Return type is "Auth | None"
httpx/httpx/_client.py: error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx._client.BaseClient.base_url
httpx/httpx/_client.py: error: Return type is partially unknown
Return type is "URL"
httpx/httpx/_client.py: error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx._client.BaseClient.cookies
httpx/httpx/_client.py: error: Return type is partially unknown
Return type is "Cookies"
httpx/httpx/_client.py: error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes"
httpx._client.BaseClient.params
httpx/httpx/_client.py: error: Return type is partially unknown
Return type is "QueryParams"
httpx/httpx/_client.py: error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes"
httpx._client.BaseClient.build_request
httpx/httpx/_client.py:319:9 - error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_client.py:319:9 - error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_client.py:319:9 - error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_client.py:319:9 - error: Return type is partially unknown
Return type is "Request"
httpx._client.Client
error: Type of base class "httpx._client.BaseClient" is partially unknown
httpx._client.Client.__init__
httpx/httpx/_client.py:624:9 - error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | None"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx/httpx/_client.py:624:9 - error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_client.py:624:9 - error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_client.py:624:9 - error: Type of parameter "proxies" is partially unknown
Parameter type is "ProxiesTypes | None"
httpx/httpx/_client.py:624:9 - error: Type of parameter "event_hooks" is partially unknown
Parameter type is "Mapping[str, List[(...) -> Unknown]] | None"
Type argument 2 for class "Mapping" has partially unknown type
httpx/httpx/_client.py:624:9 - error: Type of parameter "base_url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_client.py:624:9 - error: Type of parameter "transport" is partially unknown
Parameter type is "BaseTransport | None"
httpx/httpx/_client.py:624:9 - error: Type of parameter "app" is partially unknown
Parameter type is "((...) -> Unknown) | None"
Type annotation for parameter "args" is missing
Type annotation for parameter "kwargs" is missing
httpx._transports.base.BaseTransport.handle_request
httpx/httpx/_transports/base.py:22:9 - error: Type of parameter "request" is partially unknown
Parameter type is "Request"
httpx/httpx/_transports/base.py:22:9 - error: Return type is partially unknown
Return type is "Response"
httpx._client.Client.request
httpx/httpx/_client.py:764:9 - error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_client.py:764:9 - error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_client.py:764:9 - error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_client.py:764:9 - error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | UseClientDefault | None"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx/httpx/_client.py:764:9 - error: Return type is partially unknown
Return type is "Response"
httpx._client.Client.stream
httpx/httpx/_client.py:821:9 - error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_client.py:821:9 - error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_client.py:821:9 - error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_client.py:821:9 - error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | UseClientDefault | None"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx._client.Client.send
httpx/httpx/_client.py:872:9 - error: Type of parameter "request" is partially unknown
Parameter type is "Request"
httpx/httpx/_client.py:872:9 - error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | UseClientDefault | None"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx/httpx/_client.py:872:9 - error: Return type is partially unknown
Return type is "Response"
httpx._client.Client.get
httpx/httpx/_client.py:1025:9 - error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_client.py:1025:9 - error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_client.py:1025:9 - error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_client.py:1025:9 - error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | UseClientDefault"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx/httpx/_client.py:1025:9 - error: Return type is partially unknown
Return type is "Response"
httpx._client.Client.options
httpx/httpx/_client.py:1054:9 - error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_client.py:1054:9 - error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_client.py:1054:9 - error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_client.py:1054:9 - error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | UseClientDefault"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx/httpx/_client.py:1054:9 - error: Return type is partially unknown
Return type is "Response"
httpx._client.Client.head
httpx/httpx/_client.py:1083:9 - error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_client.py:1083:9 - error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_client.py:1083:9 - error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_client.py:1083:9 - error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | UseClientDefault"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx/httpx/_client.py:1083:9 - error: Return type is partially unknown
Return type is "Response"
httpx._client.Client.post
httpx/httpx/_client.py:1112:9 - error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_client.py:1112:9 - error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_client.py:1112:9 - error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_client.py:1112:9 - error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | UseClientDefault"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx/httpx/_client.py:1112:9 - error: Return type is partially unknown
Return type is "Response"
httpx._client.Client.put
httpx/httpx/_client.py:1149:9 - error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_client.py:1149:9 - error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_client.py:1149:9 - error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_client.py:1149:9 - error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | UseClientDefault"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx/httpx/_client.py:1149:9 - error: Return type is partially unknown
Return type is "Response"
httpx._client.Client.patch
httpx/httpx/_client.py:1186:9 - error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_client.py:1186:9 - error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_client.py:1186:9 - error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_client.py:1186:9 - error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | UseClientDefault"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx/httpx/_client.py:1186:9 - error: Return type is partially unknown
Return type is "Response"
httpx._client.Client.delete
httpx/httpx/_client.py:1223:9 - error: Type of parameter "url" is partially unknown
Parameter type is "URLTypes"
httpx/httpx/_client.py:1223:9 - error: Type of parameter "params" is partially unknown
Parameter type is "QueryParamTypes | None"
httpx/httpx/_client.py:1223:9 - error: Type of parameter "cookies" is partially unknown
Parameter type is "CookieTypes | None"
httpx/httpx/_client.py:1223:9 - error: Type of parameter "auth" is partially unknown
Parameter type is "AuthTypes | UseClientDefault"
Type of parameter "__p0" is partially unknown
Parameter type is "Request"
Return type is partially unknown
Return type is "Request"
httpx/httpx/_client.py:1223:9 - error: Return type is partially unknown
Return type is "Response"
httpx._exceptions.CloseError
error: Type of base class "httpx._exceptions.NetworkError" is partially unknown
httpx._exceptions.NetworkError
error: Type of base class "httpx._exceptions.TransportError" is partially unknown
httpx._exceptions.TransportError
error: Type of base class "httpx._exceptions.RequestError" is partially unknown
httpx._exceptions.RequestError
error: Type of base class "httpx._exceptions.HTTPError" is partially unknown
httpx._exceptions.RequestError.__init__
httpx/httpx/_exceptions.py:78:9 - error: Type of parameter "request" is partially unknown
Parameter type is "Request | None"
httpx._exceptions.HTTPError.request
httpx/httpx/_exceptions.py: error: Return type is partially unknown
Return type is "Request"
httpx/httpx/_exceptions.py: error: Type of parameter "request" is partially unknown
Parameter type is "Request"
httpx._exceptions.ConnectError
error: Type of base class "httpx._exceptions.NetworkError" is partially unknown
httpx._exceptions.ConnectTimeout
error: Type of base class "httpx._exceptions.TimeoutException" is partially unknown
httpx._exceptions.TimeoutException
error: Type of base class "httpx._exceptions.TransportError" is partially unknown
httpx._exceptions.DecodingError
error: Type of base class "httpx._exceptions.RequestError" is partially unknown
httpx._exceptions.HTTPStatusError
error: Type of base class "httpx._exceptions.HTTPError" is partially unknown
httpx._exceptions.HTTPStatusError.__init__
httpx/httpx/_exceptions.py:233:9 - error: Type of parameter "request" is partially unknown
Parameter type is "Request"
httpx/httpx/_exceptions.py:233:9 - error: Type of parameter "response" is partially unknown
Parameter type is "Response"
httpx._exceptions.HTTPStatusError.request
httpx/httpx/_exceptions.py: error: Return type is partially unknown
Return type is "Request"
httpx/httpx/_exceptions.py: error: Type of parameter "request" is partially unknown
Parameter type is "Request"
httpx._exceptions.LocalProtocolError
error: Type of base class "httpx._exceptions.ProtocolError" is partially unknown
httpx._exceptions.ProtocolError
error: Type of base class "httpx._exceptions.TransportError" is partially unknown
httpx._exceptions.PoolTimeout
error: Type of base class "httpx._exceptions.TimeoutException" is partially unknown
httpx._exceptions.ProxyError
error: Type of base class "httpx._exceptions.TransportError" is partially unknown
httpx._exceptions.ReadError
error: Type of base class "httpx._exceptions.NetworkError" is partially unknown
httpx._exceptions.ReadTimeout
error: Type of base class "httpx._exceptions.TimeoutException" is partially unknown
httpx._exceptions.RemoteProtocolError
error: Type of base class "httpx._exceptions.ProtocolError" is partially unknown
httpx._exceptions.TooManyRedirects
error: Type of base class "httpx._exceptions.RequestError" is partially unknown
httpx._exceptions.UnsupportedProtocol
error: Type of base class "httpx._exceptions.TransportError" is partially unknown
httpx._exceptions.WriteError
error: Type of base class "httpx._exceptions.NetworkError" is partially unknown
httpx._exceptions.WriteTimeout
error: Type of base class "httpx._exceptions.TimeoutException" is partially unknown
httpx._transports.asgi.ASGITransport
error: Type of base class "httpx._transports.base.AsyncBaseTransport" is partially unknown
httpx._transports.asgi.ASGITransport.__init__
httpx/httpx/_transports/asgi.py:69:9 - error: Type of parameter "app" is partially unknown
Parameter type is "(...) -> Unknown"
Type annotation for parameter "args" is missing
Type annotation for parameter "kwargs" is missing
httpx._transports.asgi.ASGITransport.handle_async_request
httpx/httpx/_transports/asgi.py:81:15 - error: Type of parameter "request" is partially unknown
Parameter type is "Request"
httpx._transports.asgi.ASGITransport.app
httpx/httpx/_transports/asgi.py:76:14 - error: Type annotation for parameter "kwargs" is missing
httpx/httpx/_transports/asgi.py:76:14 - error: Return type is unknown
httpx._transports.default.AsyncHTTPTransport
error: Type of base class "httpx._transports.base.AsyncBaseTransport" is partially unknown
httpx._transports.default.AsyncHTTPTransport.__init__
httpx/httpx/_transports/default.py:248:9 - error: Type of parameter "proxy" is partially unknown
Parameter type is "Proxy | None"
httpx._transports.default.AsyncHTTPTransport.handle_async_request
httpx/httpx/_transports/default.py:334:15 - error: Type of parameter "request" is partially unknown
Parameter type is "Request"
httpx._transports.default.HTTPTransport
error: Type of base class "httpx._transports.base.BaseTransport" is partially unknown
httpx._transports.default.HTTPTransport.__init__
httpx/httpx/_transports/default.py:113:9 - error: Type of parameter "proxy" is partially unknown
Parameter type is "Proxy | None"
httpx._transports.default.HTTPTransport.handle_request
httpx/httpx/_transports/default.py:199:9 - error: Type of parameter "request" is partially unknown
Parameter type is "Request"
httpx/httpx/_transports/default.py:199:9 - error: Return type is partially unknown
Return type is "Response"
httpx._transports.mock.MockTransport
error: Type of base class "httpx._transports.base.AsyncBaseTransport" is partially unknown
error: Type of base class "httpx._transports.base.BaseTransport" is partially unknown
httpx._transports.mock.MockTransport.__init__
httpx/httpx/_transports/mock.py:9:9 - error: Type of parameter "handler" is partially unknown
Parameter type is "(...) -> Unknown"
Type annotation for parameter "args" is missing
Type annotation for parameter "kwargs" is missing
httpx._transports.mock.MockTransport.handle_request
httpx/httpx/_transports/mock.py:12:9 - error: Type of parameter "request" is partially unknown
Parameter type is "Request"
httpx/httpx/_transports/mock.py:12:9 - error: Return type is partially unknown
Return type is "Response"
httpx._transports.mock.MockTransport.handle_async_request
httpx/httpx/_transports/mock.py:19:15 - error: Type of parameter "request" is partially unknown
Parameter type is "Request"
httpx._transports.mock.MockTransport.handler
httpx/httpx/_transports/mock.py:10:14 - error: Type annotation for parameter "kwargs" is missing
httpx/httpx/_transports/mock.py:10:14 - error: Return type is unknown
httpx._transports.wsgi.WSGITransport
error: Type of base class "httpx._transports.base.BaseTransport" is partially unknown
httpx._transports.wsgi.WSGITransport.__init__
httpx/httpx/_transports/wsgi.py:66:9 - error: Type of parameter "app" is partially unknown
Parameter type is "(...) -> Unknown"
Type annotation for parameter "args" is missing
Type annotation for parameter "kwargs" is missing
httpx._transports.wsgi.WSGITransport.handle_request
httpx/httpx/_transports/wsgi.py:80:9 - error: Type of parameter "request" is partially unknown
Parameter type is "Request"
httpx/httpx/_transports/wsgi.py:80:9 - error: Return type is partially unknown
Return type is "Response"
httpx._transports.wsgi.WSGITransport.app
httpx/httpx/_transports/wsgi.py:74:14 - error: Type annotation for parameter "kwargs" is missing
httpx/httpx/_transports/wsgi.py:74:14 - error: Return type is unknown
Symbols exported by "httpx": 67
With known type: 18
With ambiguous type: 1
With unknown type: 48
Functions without docstring: 2
Functions without default param: 132
Classes without docstring: 0
Other symbols referenced but not exported by "httpx": 1109
With known type: 988
With ambiguous type: 11
With unknown type: 110
Type completeness score: 26.9%
Completed in 0.669sec
Type completeness score: 26.9%
- Is anyone able to show us an screenshot example of VSCode having an issue with the
httpx
public interface?
This is a lot more manual. I've been including them in my PRs but it'd be very hard to take a screenshot of every issue.
Ideally we’d have any checks here integrated into our tooling. I don’t know if there are any
mypy
options that’d get us close enough to pyright’s different expectations.
In my experience running mypy in strict mode is "close enough". The trick is we'd have to have mypy in strict mode pass on our tests to reproduce the "user experience". I think this should ultimately be the end goal, but we'll probably have to start by cleaning up typing without CI enforcement, then enforce mypy strict mode on all/some of the httpx
module and finally on tests.
We could also consider adding
pyright
checking to our CI scripts. Although failing to be able topip install pyright
and end up with a working installation is being a bit of a blocker from what I can see.
I have never had luck with this; I think mypy in strict mode will do
As for this PR: I'm guessing it was larger before but now it's pretty well self contained, I'm inclined to move forward with it if you don't have any objections @tomchristie
Thanks @relsunkaev!