Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Question about httpx.Client constructor parameter proxies #2131

Closed
chagui opened this issue Mar 17, 2022 · 2 comments
Closed

Question about httpx.Client constructor parameter proxies #2131

chagui opened this issue Mar 17, 2022 · 2 comments
Labels
question Further information is requested

Comments

@chagui
Copy link

chagui commented Mar 17, 2022

Hello,
Thanks for the great library!

I just ran into a mypy error for the following code.

def fun(proxies: httpx.Proxy | None) -> None:
    with httpx.Client(proxies=proxies):
        pass
error: Argument "proxies" to "Client" has incompatible type "Optional[Proxy]"; expected "Union[Union[URL, str], Proxy, Dict[Union[URL, str], Union[None, Union[URL, str], Proxy]]]"  [arg-type]
Found 1 error in 1 file (checked 1 source file)

I find this surprising because the httpx.Client constructor parameter proxies is advertised as optional:

  • proxies - (optional) A dictionary mapping proxy keys to proxy
    URLs.

https://github.com/encode/httpx/blob/master/httpx/_client.py#L598-L599

It's also the default value for the parameter:

proxies: ProxiesTypes = None,

https://github.com/encode/httpx/blob/master/httpx/_client.py#L626

Should the type be changed to typing.Optional[ProxiesTypes] or am I missing something?

I could not find any existing issue related to this but if I somehow miss it feel free to point me to it and close this one 😇

@chagui chagui changed the title Question about httpx.Client constructor paramter proxies Question about httpx.Client constructor parameter proxies Mar 17, 2022
@florimondmanca
Copy link
Member

florimondmanca commented Mar 17, 2022

Hi @chagui, are you using mypy --strict? If so, this might be related to #2092.

How does def fun(proxies: httpx.Proxy = None) do ?

@florimondmanca florimondmanca added the question Further information is requested label Mar 17, 2022
@florimondmanca
Copy link
Member

I'm tentatively moving this to Discussions for now, since we try to keep Issues for well-defined work items.

@encode encode locked and limited conversation to collaborators Mar 17, 2022
@florimondmanca florimondmanca converted this issue into discussion #2132 Mar 17, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants