-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: Refactor open into context manager in io tests #21139
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
Conversation
fh = open(p, 'wb') | ||
fh.write(s) | ||
fh.close() | ||
with open(p, 'wb') as fh: |
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.
Do we have a name used more often than not for the file handle? I notice in this change we have two different ones. The last file I touched they were all as f:
- if that's used more often than not then let's update these to stay consistent
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.
f or fh is prob ok
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.
@WillAyd : I think this is one of those gray areas where consistency and semantics are somewhat at odds. It's true that using as f
would render it consistent, but names like outfile
(as below) have their merit as providing more information about the file's usage.
Codecov Report
@@ Coverage Diff @@
## master #21139 +/- ##
=======================================
Coverage 91.84% 91.84%
=======================================
Files 153 153
Lines 49499 49499
=======================================
Hits 45460 45460
Misses 4039 4039
Continue to review full report at Codecov.
|
thanks! |
git diff upstream/master -u -- "*.py" | flake8 --diff
Building on #21105 by @WillAyd, I cleaned up some more
open
statements.