Skip to content
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

Installing types-requests breaks urllib3 2.0 type hints #10786

Closed
pquentin opened this issue Sep 27, 2023 · 2 comments
Closed

Installing types-requests breaks urllib3 2.0 type hints #10786

pquentin opened this issue Sep 27, 2023 · 2 comments

Comments

@pquentin
Copy link
Contributor

requests 2.31.0 depends on urllib3, and supports both urllib3 1.21.x and urllib3 2.0.x. requests does not have inline type hints. urllib3 1.x did not have inline type hints, we introduced them in urllib3 2.0, as correctly identified here:

obsolete_since = "2.0.0" # Released on 2023-04-26

However, when taking advantages of urllib3 2.0 type hints in a file like this:

import urllib3.connection


class HTTPSConnection(urllib3.connection.HTTPSConnection):
    def connect(self) -> None:
        super().connect()
        self.foo = "bar"

mypy --strict t.py reports no error, unless I run pip install types-requests, which installs types-requests 2.31.0.6 AND types-urllib3 1.26.25.14. At this point, the typeshed package takes precedence even if I'm using urllib3 2.0.5 at runtime, and mypy --strict t.py reports:

t.py:6: error: Call to untyped function "connect" in typed context  [no-untyped-call]
Found 1 error in 1 file (checked 1 source file)

The manual fix is to manually uninstall types-urllib3, but is there a way to make this work without manual intervention?

@AlexWaygood
Copy link
Member

AlexWaygood commented Sep 27, 2023

Thanks for filing the issue!

We'd like to change our types-requests package so that it depends on urllib3 rather than types-urllib3. Unfortunately, doing so breaks our tests due to a limitation of how our CI is set up -- our tests start complaining about differences between our outdated stubs for urllib3 and the inline types in the runtime package for urllib3, and it's all a bit of a mess.

However, good news! In four days, we're due to remove our stubs for urllib3 from typeshed (#6898). Once we do so, we can easily change types-requests so that it depends on urllib3 rather than types-urllib3, which will resolve this issue for you.

TL;DR: closing as a duplicate of #10142 ;)

@AlexWaygood AlexWaygood closed this as not planned Won't fix, can't repro, duplicate, stale Sep 27, 2023
@AlexWaygood
Copy link
Member

AlexWaygood commented Oct 1, 2023

@pquentin hopefully this is resolved with types-requests>=2.31.0.7?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants