-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
types-requests>=2.31.0.7
can't be installed alongside urllib3<2
#10825
Comments
If you have a requirements file that also includes a package that pins |
|
@AlexWaygood My goal is always to use the most recent version of every dependency that I can without breaking my systems. I use an automated process ( So yes, I am pinning a specific version. But... it seems to me that you've taken a step to optimize your development process -- I don't know what these stubs do so I can't comment on the value added -- and this comes at the expense of the users of your library. Put another way: it seems obvious to me that the latest version of |
To be clear, without this change, it was painful for our users to use |
It seems like there are two obvious alternatives:
|
Stubs are never executed at runtime. In a runtime package you might do something like this to resolve this problem... try:
import urllib3
except ImportError:
urllib3 = None
else:
if int(urllib3.__version__.split(".")[0]) < 2:
urllib3 = None
if urllib3 is None:
import types_urllib3 as urllib3 ...but that's out of the question for a stubs package, unfortunately, since a stubs package entirely consists of "data files" that are to be read by a static type checker. All of that stuff is way too dynamic for a type checker to understand; |
It seems like your implementation choices are getting in the way. I'm going to assume that these choices aren't up for debate at this time. A few options to consider:
|
Just ran into this change and I do agree with the @jessemyers-lettuce above on:
If that's not the expected behavior, I wouldn't expect such a major change to be introduced as a part of a patch to a patch (v2.31.0.7). This should at the very least, be a minor version update, and ideally a breaking change. |
We are also encountering an issue with this change. Semgrep does not support urllib3 > 1.26 in their latest version. The ensuing pip conflict means we are unable to build a number of services which use both semgrep and types-requests. We will pin types-requests to an older version for the time being. |
Thanks everyone for chiming in! Stub version numbers primarily reflect the version of the upstream package that they represent. This is important as it lets users more clearly type check their code based on the versions of upstream packages they're using. Therefore, changes to stubs that are not retargeting to a different upstream version end up changing later digits in the version (also basically every change to a stub can change type checker behaviour, so hard to ascribe too much semantic meaning to them) I agree it would have been nice if we'd had the foresight to bundle this change in with a version bump in upstream requests, but as it stands, there's not too much to be done. Dependency resolvers should be able to handle this and figure out a compatible set of packages just fine. You're welcome to manually pin to older types-requests as well. |
types-requests>=2.31.0.7
can't be installed alongside urllib3<2
I agree with @AlexWaygood and @hauntsaninja here. There is not much that can be done on typeshed's side. The underlying issue is that boto depends on an old version of urllib3. (The underlying underlying issue is the flat namespace of Python imports, which is not something that will change in the short run or ever.) While I understand that it's frustrating to deal with this issue, this is worked around by using proper dependency management (which should prevent newer versions of types-requests to be installed) and/or pinning the types-requests dependency. |
I have read the comments. While I see all the challenges, closing this issue is unsatisfactory. My setup:
Installing the types via mypy will have this effect:
Installing type information now has an effect on the installed libraries and breaks the setup. |
@aquamatthias that does sound unfortunate. I'm sorry for the disruption we've caused to your workflow here. FWIW, I'd strongly recommend against using Since you're using poetry, have you considered adding a dev-dependency group of optional requirements, to list the stubs packages that are required to type-check your project with mypy? |
@AlexWaygood Yes - that is our solution for types-requests. We probably should define all of them as suggested. |
Let me start by saying that I understand that there are limits in terms of what this project can do. That said, I worry about two things in particular:
|
@AlexWaygood @hauntsaninja @srittau : Thanks for engaging and responding. Appreciate the work you'll are doing in maintaining the stubs. The problem here, IMHO, is two-fold:
Thank you for suggesting the workarounds, and we have (as I'm sure others have) already implemented them in their workflows. That doesn't change the fact that this is an issue worth fixing and has been hurriedly closed without regard for fair points and concerns. |
Typeshed versions work the way they do due to technical limitations. Other schemes were debated, but had significant drawbacks. That said, this discussion showed that we need to communicate our versioning policy better and we could possibly iterate on the exact way we use versions. I've opened #10837 to further discuss this. |
I think I agree with the approach Perhaps it would be useful to add a note somewhere prominent that users should pin your lib as |
@calpaterson I tried to flag this as loudly as I could in the CHANGELOG entry, which is linked to from the PyPI page for |
@jessemyers-lettuce I think you're raising very reasonable points about our inadequate documentation here around our versioning scheme. I myself don't fully understand all the ins and outs of it. We need to do better here. Whether or not we change our versioning scheme (discussed at typeshed-internal/stub_uploader#104 initially, but the discussion is now continuing at #10837), we have to do better at communicating it. I'm going to try to write up some better documentation for us at some point in the next few days. (EDIT: @srittau beat me to it! #10840 has now been filed to improve our documentation here.) |
@setu4993, to be clear, this was already the case prior to the change that happened here. Prior to this change, What's changed is three things:
|
@AlexWaygood Thanks for the detailed and thoughtful response and I'm glad that versioning will be communicated more clearly. re:
I think it's important to recognize that there are two different kinds of incompatibility here and that most people care first about runtime compatibility and second about type definition compatibility. The move towards explicitness re: type definitions now has an impact on runtime, which is why everyone is surprised. |
Yep, I get that, and I'd like to apologise again for not anticipating in advance how disruptive/unexpected this change would be. The idea of having typeshed stubs that depend on external runtime packages is still ~pretty new (#5768 was only closed in January), so to some extent we're still figuring out this brave new world. I think we were probably focussed too much on the many alterations that were needed to our testing infrastructure to make that change, and didn't think enough about communicating the full implications of that change to our users. |
Thanks for engaging constructively and in good spirit through this discussion.
While this is correct, the mismatch IMHO lies in the fact that prior to this change Maybe just me, but incorrectly validated / missing type definitions is better than incorrect type definitions which don't match against the latest upstream package / fixes. @jessemyers-lettuce correctly summarized the distinction as:
I do think better documentation as in #10840 (thank you!) do help atleast raise awareness about what expectations users should have from type definitions. This has also been an (or atleast one of) impetus to push for other packages to adopt |
FWIW, we've also been trying to improve the generated PyPI descriptions for these stubs packages: typeshed-internal/stub_uploader@1feee28 Here's an example of what the new-style descriptions look like: https://pypi.org/project/types-Markdown/3.5.0.0/ (It'll take a while for this to filter through into the PyPI descriptions for all our existing stubs packages; they'll only get new PyPI releases as and when they get updates at typeshed. |
This PR creates a breaking change because it adds:
As of this writing,
requests
itself has this dependency declaration:This means that there are scenarios where
requests
can be installed, buttypes-requests
cannot.In my case, I am using
boto3
andbotocore
for AWS interactions and it defines its ownurllib3
dependency range that produces this incompatiblity:Please consider aligning the
types-requests
version ranges to the same bounds thatrequests
itself uses.The text was updated successfully, but these errors were encountered: