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

[requests] Improve RequestException and subclasses #10734

Closed
wants to merge 1 commit into from

Conversation

intgr
Copy link
Contributor

@intgr intgr commented Sep 19, 2023

RequestException.request and RequestException.response were untyped.

Relevant code: https://requests.readthedocs.io/en/latest/_modules/requests/exceptions/#RequestException

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

cloud-init (https://github.com/canonical/cloud-init)
+ cloudinit/url_helper.py:343: error: Item "None" of "Response | None" has no attribute "status_code"  [union-attr]
+ cloudinit/url_helper.py:344: error: Item "None" of "Response | None" has no attribute "headers"  [union-attr]

poetry (https://github.com/python-poetry/poetry)
+ src/poetry/publishing/uploader.py:35: error: Item "None" of "Response | None" has no attribute "status_code"  [union-attr]
+ src/poetry/publishing/uploader.py:35: error: Item "None" of "Response | None" has no attribute "reason"  [union-attr]
+ src/poetry/publishing/uploader.py:35: error: Item "None" of "Response | None" has no attribute "content"  [union-attr]

twine (https://github.com/pypa/twine)
+ twine/__main__.py:36: error: Item "None" of "Response | None" has no attribute "status_code"  [union-attr]
+ twine/__main__.py:39: error: Item "None" of "Response | None" has no attribute "url"  [union-attr]
+ twine/__main__.py:39: error: Item "None" of "Response | None" has no attribute "reason"  [union-attr]

materialize (https://github.com/MaterializeInc/materialize)
+ misc/python/materialize/cloudtest/util/web_request.py:27: error: Item "None" of "Response | None" has no attribute "status_code"  [union-attr]
+ misc/python/materialize/cloudtest/util/web_request.py:28: error: Item "None" of "Response | None" has no attribute "reason"  [union-attr]
+ misc/python/materialize/cloudtest/util/web_request.py:29: error: Item "None" of "Response | None" has no attribute "content"  [union-attr]
+ misc/python/materialize/cloudtest/util/web_request.py:70: error: Item "None" of "Response | None" has no attribute "status_code"  [union-attr]
+ misc/python/materialize/cloudtest/util/web_request.py:102: error: Item "None" of "Response | None" has no attribute "status_code"  [union-attr]
+ misc/python/materialize/cloudtest/util/web_request.py:134: error: Item "None" of "Response | None" has no attribute "status_code"  [union-attr]
+ misc/python/materialize/cloudtest/util/web_request.py:172: error: Item "None" of "Response | None" has no attribute "status_code"  [union-attr]

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]
+ src/schemathesis/cli/output/default.py: note: In function "display_service_error":
+ src/schemathesis/cli/output/default.py:357: error: Item "None" of "Optional[Response]" has no attribute "status_code"  [union-attr]
+ src/schemathesis/cli/__init__.py: note: In function "handle_service_error":
+ src/schemathesis/cli/__init__.py:1198: error: Item "None" of "Optional[Response]" has no attribute "status_code"  [union-attr]
+ src/schemathesis/cli/__init__.py:1199: error: Item "None" of "Optional[Response]" has no attribute "json"  [union-attr]
+ src/schemathesis/cli/__init__.py:1200: error: Item "None" of "Optional[Response]" has no attribute "status_code"  [union-attr]
+ src/schemathesis/cli/__init__.py: note: In function "login":
+ src/schemathesis/cli/__init__.py:1316: error: Item "None" of "Optional[Response]" has no attribute "json"  [union-attr]

openlibrary (https://github.com/internetarchive/openlibrary)
+ openlibrary/catalog/get_ia.py: note: In function "urlopen_keep_trying":
+ openlibrary/catalog/get_ia.py:25: error: Item "None" of "Response | None" has no attribute "status_code"  [union-attr]

@AlexWaygood
Copy link
Member

@intgr
Copy link
Contributor Author

intgr commented Sep 19, 2023

Oops, sorry, it didn't occur to check existing issues/PRs.

@intgr
Copy link
Contributor Author

intgr commented Sep 19, 2023

Closing as duplicate of #8989

@intgr intgr closed this Sep 19, 2023
@intgr intgr deleted the improve-requests-exceptions branch October 1, 2023 13:54
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.

2 participants