Skip to content

Fix code style issues flagged by LGTM #1559

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 4 commits into from
Sep 27, 2022

Conversation

chrisorner
Copy link
Contributor

@chrisorner chrisorner commented Sep 27, 2022

  • Closes LGTM has 6 errors  #1275
  • I am familiar with the contributing guidelines
  • Pull request is nearly complete and ready for detailed review.
  • Maintainer: Appropriate GitHub Labels (including remote-data) and Milestone are assigned to the Pull Request and linked Issue.

@AdamRJensen
Copy link
Member

AdamRJensen commented Sep 27, 2022

@chrisorner thanks for fixing these issues! There's two minor issues flagged by stickler (lines that are too long)

I suppose an entry into the appropriate whatsnew file would be appreciated - you can go ahead and add your name to the list of contributors too :)

Copy link
Member

@kandersolar kandersolar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @chrisorner! I'll trigger the tests to make sure everything still works, but here are a couple comments in the meantime.

try:
data, meta = parse_epw(csvdata, coerce_year)
except Exception as e:
print(e)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we definitely want to propagate any parsing errors instead of printing them and letting execution continue, so better to get rid of the try/excepts in these two blocks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @chrisorner for the contribution and closing a long-standing annoying issue, and also thanks @kanderso-nrel for quick and thoughtful review. I apologize for commenting after the fact. I agree with Kevin (altho he might not agree with me). In my opinion we should restrict using print() in pvlib, except perhaps in examples, b/c it blocks the main execution thread which reduces performance. An alternative is logging which has many useful features, executes in separate thread, and therefore, does not block the main Python thread. However, as a rule pvlib has avoided logging except during development. Hope this makes sense to folks. Just my thoughts/opinions, definitely do not speak for anyone other than myself.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikofski just to be sure, would you change anything about the state of this PR as it was merged? Note that this printing was removed in a later commit and didn't make it into the final squashed diff.

I definitely agree that print() inside pvlib itself is never (or at least very rarely) the best way to present information to the user.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, no changes. I was very happy with this PR and the review. Thanks again! Just wanted to make sure it was in the record that I extremely discourage print(), and I consider logging a better alternative although to date, hasn't been used in pvlib much.

@kandersolar kandersolar added this to the 0.9.4 milestone Sep 27, 2022
@kandersolar kandersolar changed the title fixing issues Fix code style issues flagged by LGTM Sep 27, 2022
@kandersolar kandersolar added the remote-data triggers --remote-data pytests label Sep 27, 2022
Copy link
Member

@kandersolar kandersolar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codecov failure can be ignored. Thanks again @chrisorner

@kandersolar kandersolar merged commit bdbaf4c into pvlib:master Sep 27, 2022
@chrisorner chrisorner deleted the fix_issue_from_lgtm branch September 27, 2022 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement remote-data triggers --remote-data pytests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LGTM has 6 errors
5 participants