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

Added static typing to data.py and filepath_or_buffer.py #682

Merged
merged 3 commits into from
Oct 7, 2022

Conversation

Sanketh7
Copy link
Contributor

@Sanketh7 Sanketh7 commented Oct 7, 2022

@taylorfturner taylorfturner added the static_typing mypy static typing issues label Oct 7, 2022
@taylorfturner taylorfturner enabled auto-merge (squash) October 7, 2022 14:24
"""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
Copy link
Contributor

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__
Copy link
Contributor

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

@taylorfturner taylorfturner merged commit a791acd into capitalone:main Oct 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
static_typing mypy static typing issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants