You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Switch to explicit typing.Optional throughout #2092
repro.py:9: note: Revealed type is "httpx._client.AsyncClient*"
Output with strict = true:
repro.py:8: error: Need type annotation for "http_client" [var-annotated]
repro.py:8: error: Argument 1 to "enter_async_context" of "AsyncExitStack" has incompatible type "AsyncClient"; expected "AsyncContextManager[<nothing>]" [arg-type]
repro.py:9: note: Revealed type is "Any"
Found 2 errors in 1 file (checked 1 source file)
I initially raised an issue at python/mypy#12226 but it looks to be an issue with httpx. They said
Yup, this seems correct and well scoped, I guess at this point a PR attempting to fix that type annotation to Optional and see if it resolves this item would be on point.
If no one has picked this up yet, I'm happy to take a crack at it.
I've been working on it a little bit and I've got the total number of errors from mypy --strict httpx down from 437 to 207, just by adding typing.Optional or adding None to some already existing typing.Union definitions (e.g. httpx._types.HeaderTypes).
Happy to continue the work and open a PR if people are interested.
Activity
[-]Issue with Mypy `--strict` and ``[/-][+]Issue with Mypy `--strict` and `AsyncExitStack`[/+]florimondmanca commentedon Feb 26, 2022
Hi @michaeloliverx,
Yup, this seems correct and well scoped, I guess at this point a PR attempting to fix that type annotation to
Optionaland see if it resolves this item would be on point.lovelydinosaur commentedon Feb 28, 2022
Perhaps we should re-title this as the more general case.
Something like "Switch to explicit typing.Optional throughout" (?)
[-]Issue with Mypy `--strict` and `AsyncExitStack`[/-][+]Switch to explicit typing.Optional throughout[/+]lovelydinosaur commentedon Feb 28, 2022
See also #1760, #1747
nhoad commentedon Mar 4, 2022
If no one has picked this up yet, I'm happy to take a crack at it.
I've been working on it a little bit and I've got the total number of errors from
mypy --strict httpxdown from 437 to 207, just by addingtyping.Optionalor addingNoneto some already existingtyping.Uniondefinitions (e.g.httpx._types.HeaderTypes).Happy to continue the work and open a PR if people are interested.
florimondmanca commentedon Mar 5, 2022
@nhoad Hi, FYI it looks like there's initial work on this here: #2096