-
-
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
requests: type RequestException members (not Any) #8989
Conversation
This comment has been minimized.
This comment has been minimized.
Looks like this triggered a bunch of issues in repos, should be possible to make more precise by specifying that HTTPError always has them set (not sure about this assumption, though). |
This comment has been minimized.
This comment has been minimized.
As far as I can tell, this is the only internal construction of `ConnectionError` that doesn't include `request` or `response`. Part of improving typing for exceptions in requests: python/typeshed#8989
If psf/requests#6270 is considered mergeable/correct, that means we can further specify |
Thanks! Let's wait for resolution on the requests PR so that we can merge this without the mypy-primer regression. |
This comment has been minimized.
This comment has been minimized.
Diff from mypy_primer, showing the effect of this PR on open source code: schemathesis (https://github.com/schemathesis/schemathesis)
+ src/schemathesis/models.py: note: In member "call" of class "Case":
+ src/schemathesis/models.py:340: error: Argument 2 to "_get_code_message" of "Case" has incompatible type "Optional[Request]"; expected "PreparedRequest" [arg-type]
+ src/schemathesis/models.py: note: At top level:
+ src/schemathesis/runner/events.py: note: In member "from_exc" of class "InternalError":
+ src/schemathesis/runner/events.py:195: error: Item "None" of "Optional[Request]" has no attribute "url" [union-attr]
|
Maybe we can live with the regression and merge this as is? As long as psf/requests#6270 isn't merged, |
Given that it's been almost a year, I agree. I'll wait a day or so in case other typeshed maintainers disagree, then merge this PR. |
Thought it was weird that
mypy
didn't catch the following:Hopefully this is a reasonable change.