Skip to content

Add hint for requests.models.Response.raw - #12616

Merged
srittau merged 2 commits into
python:mainfrom
adamtheturtle:type-requests-response-raw
Sep 4, 2024
Merged

srittau merged 2 commits into
python:mainfrom
adamtheturtle:type-requests-response-raw

Conversation

@adamtheturtle

Copy link
Copy Markdown
Contributor

@github-actions

This comment has been minimized.

@adamtheturtle

Copy link
Copy Markdown
Contributor Author

It looks to me like the added errors are genuine / reasonable.

@srittau

srittau commented Sep 4, 2024

Copy link
Copy Markdown
Collaborator

Considering that users can rely on raw being not None when they use it in a response, using _typeshed.MaybeNone instead of None is probably the better option. Just took a brief look at the sphinx primer hit, and their code seems to be correct.

@adamtheturtle

Copy link
Copy Markdown
Contributor Author

Thank you @srittau I wasn't aware of MaybeNone and that sounds sensible. I have pushed that change.

@github-actions

github-actions Bot commented Sep 4, 2024

Copy link
Copy Markdown
Contributor

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

sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/ext/intersphinx/_load.py: note: In function "_read_from_url":
+ sphinx/ext/intersphinx/_load.py:383:5: error: Cannot assign to a method  [method-assign]
+ sphinx/ext/intersphinx/_load.py:383:18: error: "Callable[[int | None, bool | None, bool], bytes] | Any" not callable  [misc]
+ sphinx/ext/intersphinx/_load.py:384:12: error: Incompatible return value type (got "HTTPResponse | Any", expected "IO[Any]")  [return-value]

@srittau
srittau merged commit 59f612f into python:main Sep 4, 2024
@adamtheturtle
adamtheturtle deleted the type-requests-response-raw branch September 4, 2024 10:16
max-muoto pushed a commit to max-muoto/typeshed that referenced this pull request Sep 8, 2024
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