-
Notifications
You must be signed in to change notification settings - Fork 165
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
Added static typing to data.py and filepath_or_buffer.py #682
Conversation
"""Release resources.""" | ||
# Need to detach buffer if wrapped (i.e. BytesIO opened with 'r') | ||
if self._is_wrapped: | ||
self._filepath_or_buffer = cast(TextIOWrapper, self._filepath_or_buffer) # guaranteed by self._is_wrapped |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
potential for follow-up around casting and ensuring typing declaration is right and/or code is corrected to avoid the change of a wrong type
wrapper = self._filepath_or_buffer | ||
self._filepath_or_buffer = wrapper.buffer | ||
wrapper.detach() | ||
|
||
if isinstance(self._filepath_or_buffer, (StringIO, BytesIO)): | ||
self._filepath_or_buffer.seek(0) | ||
else: | ||
self._filepath_or_buffer = cast(IO, self._filepath_or_buffer) # can't be str due to conversion in __enter__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
potential for follow-up around casting and ensuring typing declaration is right and/or code is corrected to avoid the change of a wrong type
#610