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

Update config.py #423

Merged
merged 1 commit into from
Oct 27, 2017
Merged

Update config.py #423

merged 1 commit into from
Oct 27, 2017

Conversation

ajiteshr7
Copy link
Contributor

@ajiteshr7 ajiteshr7 commented Oct 23, 2017

Better file handling

Increase code coverage.
@thinkingserious thinkingserious added the status: code review request requesting a community code review or review from Twilio label Oct 23, 2017
@SendGridDX
Copy link

SendGridDX commented Oct 23, 2017

CLA assistant check
All committers have signed the CLA.

@codecov-io
Copy link

codecov-io commented Oct 23, 2017

Codecov Report

Merging #423 into master will decrease coverage by 0.16%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #423      +/-   ##
==========================================
- Coverage   81.54%   81.38%   -0.17%     
==========================================
  Files           9        9              
  Lines         981      983       +2     
  Branches      156      156              
==========================================
  Hits          800      800              
- Misses         90       92       +2     
  Partials       91       91
Impacted Files Coverage Δ
sendgrid/helpers/inbound/config.py 75.75% <0%> (-4.89%) ⬇️

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 0884519...428a9ae. Read the comment docs.

@mbernier
Copy link
Contributor

mbernier commented Oct 24, 2017

Can you please help a newer Python dev understand why this is better? It seems the previous way is a bit cleaner?

@ajiteshr7
Copy link
Contributor Author

ajiteshr7 commented Oct 24, 2017

As when opening a file in 'for loop' we aren't keeping any explicit reference to the opened file. Hence to close the file we need to get dependent on the garbage collector, but that may mean that the resources aren't freed in a timely manner. Also if an exception occurs file will not get closed when using for ... open.
Python provides with to handle these cases and using with makes the code more readable.
More on this here.

@mbernier
Copy link
Contributor

Awesome, thank you for explaining this change @ajiteshr7!!

@mbernier mbernier added difficulty: medium fix is medium in difficulty hacktoberfest labels Oct 27, 2017
@mbernier mbernier merged commit 30d8b56 into sendgrid:master Oct 27, 2017
@thinkingserious
Copy link
Contributor

Hello @ajiteshr7,

Thanks again for the PR!

It's HACKTOBERFEST! We want to show our appreciation by sending you some special Hacktoberfest swag. If you have not already, could you please fill out this form so we can send it to you? Thanks!

Team SendGrid DX

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: medium fix is medium in difficulty status: code review request requesting a community code review or review from Twilio
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants