-
Notifications
You must be signed in to change notification settings - Fork 128
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
Enforce types to io.open_file
#1250
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
victorlin
force-pushed
the
victorlin/update-open_file
branch
from
July 3, 2023 18:30
0eccb7f
to
0a7612e
Compare
This function is written in a way that supports more than just StringIO.
victorlin
force-pushed
the
victorlin/update-open_file
branch
from
July 3, 2023 19:08
0a7612e
to
b004bfe
Compare
tsibley
approved these changes
Jul 5, 2023
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.
Seems reasonable!
victorlin
force-pushed
the
victorlin/update-open_file
branch
from
July 5, 2023 20:55
b004bfe
to
69145f6
Compare
victorlin
force-pushed
the
victorlin/update-open_file
branch
from
July 5, 2023 20:56
69145f6
to
205b70e
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #1250 +/- ##
==========================================
+ Coverage 68.96% 68.97% +0.01%
==========================================
Files 64 64
Lines 6946 6949 +3
Branches 1696 1698 +2
==========================================
+ Hits 4790 4793 +3
Misses 1851 1851
Partials 305 305
☔ View full report in Codecov by Sentry. |
joverlee521
reviewed
Jul 5, 2023
Previously, anything that couldn't be opened with xopen would be returned as-is. The docstring described a type restriction on path_or_buffer but it was not enforced. Instead of adding a compile-time type restriction on path_or_buffer, add run-time type restrictions by using type narrowing¹ to provide clear context to static type checkers and raise a meaningful error if the type is not supported. ¹ https://mypy.readthedocs.io/en/stable/type_narrowing.html
victorlin
force-pushed
the
victorlin/update-open_file
branch
from
July 5, 2023 21:51
205b70e
to
2d02ec2
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of proposed changes
Previously, the documentation described a type restriction on
path_or_buffer
, but it was not enforced. This PR updates the type restrictions and enforces them.Related issue(s)
N/A, motivated by the recent adoption of Mypy type checking.
Testing
Checklist