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

Respect HTTPError spec #1693

Merged
merged 3 commits into from
Sep 25, 2023
Merged

Respect HTTPError spec #1693

merged 3 commits into from
Sep 25, 2023

Conversation

Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Sep 25, 2023

HTTPError has 2 attributes request and response. Both are expected by users to be not None but it was not really enforced at any level (typed as Any). Since types-requests==2.31.0.4, the types are now enforced to be requests.Request and response.Response. This PR adapts the current code to set the request/response attributes correctly whenever possible. However this is not always possible due to how our errors are built (it happens in rare cases that we raise a HTTPError even though it's not really a HTTPError per-se). I think enforcing request/response whenever possible + ignore other errors is fine for now. Let's reassess if at any point some users complain.

See the related python/typeshed#8989 and python/typeshed#10740.

@Wauplin Wauplin mentioned this pull request Sep 25, 2023
7 tasks
@Wauplin Wauplin merged commit d9a0eea into main Sep 25, 2023
3 checks passed
@Wauplin Wauplin deleted the fix-mypy-requests branch September 25, 2023 08:32
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

Successfully merging this pull request may close these issues.

1 participant