Add explicit type hints for public properties in Response
#2964
Unanswered
RobertCraigie
asked this question in
Potential Issue
Replies: 1 comment 1 reply
-
|
I'm not sure... >>> from typing_extensions import reveal_type
>>> from httpx import Response
>>>
>>> r = Response(status_code=200)
>>> assert r.is_stream_consumed is False
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AssertionErrorAre you sure you're not seeing the "error: unreachable" because there's an incorrect assertion there? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Mypy will report an error for this code:
This is because mypy's inference algorithm doesn't properly handle the
is_stream_consumedassignment and thinks thatr.is_stream_consumedcan only ever beFalse. While this is also completely a mypy bug, imo it is always helpful to explicitly declare the types for class properties and in this case would obviate the mypy bug.I'd happily open a PR for this if the change would be acceptable.
Beta Was this translation helpful? Give feedback.
All reactions