Skip to content

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

Merged
merged 1 commit into from
May 21, 2018
Merged

CLN: Refactor open into context manager in io tests #21139

merged 1 commit into from
May 21, 2018

Conversation

alysivji
Copy link
Contributor

  • closes #xxxx
  • tests added / passed
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

Building on #21105 by @WillAyd, I cleaned up some more open statements.

fh = open(p, 'wb')
fh.write(s)
fh.close()
with open(p, 'wb') as fh:
Copy link
Member

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

Copy link
Contributor

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

Copy link
Member

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

codecov bot commented May 20, 2018

Codecov Report

Merging #21139 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #21139   +/-   ##
=======================================
  Coverage   91.84%   91.84%           
=======================================
  Files         153      153           
  Lines       49499    49499           
=======================================
  Hits        45460    45460           
  Misses       4039     4039
Flag Coverage Δ
#multiple 90.23% <ø> (ø) ⬆️
#single 41.88% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bc37ea2...35a3dc4. Read the comment docs.

@jreback jreback added this to the 0.24.0 milestone May 21, 2018
@jreback jreback merged commit 3cae0a2 into pandas-dev:master May 21, 2018
@jreback
Copy link
Contributor

jreback commented May 21, 2018

thanks!

@alysivji alysivji deleted the cleanup-context-manager branch May 21, 2018 12:00
david-liu-brattle-1 pushed a commit to david-liu-brattle-1/pandas that referenced this pull request Jun 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants