-
Notifications
You must be signed in to change notification settings - Fork 5
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
Format and Lint existing python files #317
Conversation
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.
Thanks for setting up more robust linting. However, it looks like there might be some changes to the order of the import statements which may break things that I flagged for you to look into. Since there were some non-formatting changes made, it may be worth quickly testing the pipeline using the --small
run to make sure that everything is still working.
# exclude = ["*.ipynb"] | ||
|
||
[tool.ruff.lint.pydocstyle] | ||
convention = "google" |
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.
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.
This is what I found in the README under Conventions and Standards
Line 179 in 1ff871f
- Functions should include descriptive docstrings (using the Google style guide https://google.github.io/styleguide/pyguide.html#383-functions-and-methods), inline comments should be used to describe individual steps, and variable names should be made descriptive (e.g. `cems_plants_with_missing_co2_data` not `cems_missing` or `cpmco2`) |
This may be a good practice. Is this something that could be auto-formatted if enforced, or would we need to manually edit all of the comments? If we can auto-format, we should probably do it. |
These are the issues when we add E501:
None are fixable using |
That's a long list. Would be nice to fix this over time, but not sure that it's a priority right now. Maybe we ignore this error for now. I'm going to add a vertical ruler at 88 characters to my vscode settings so that I can notice when a line is too long and fix over time. |
Docstring and comments are easily fixable. The hard work is breaking (f-)strings in |
6e1e483
to
78d1c65
Compare
@grgmiller , running python data_pipeline.py --year 2021 --small leads to the following error:
I fixed this issue in 277a74a as part of PR #313. Three options:
What do you prefer? |
It looks like that was a one-line code change. Can you just make the same change in this branch and commit it here as well? I just left some comments on the other PR to try and get that merged in soon as well. |
@grgmiller, I have rebased this branch onto I believe it is ready to be merged. |
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.
Thanks Ben, I think we may want to save merging this PR until after we've refactored the code with all the 2022 updates- I'm just afraid of a bunch of conflicts that will have to be resolved manually since we're doing some major updates. We'll want to re-apply the auto linting to the new code once refactored. Maybe as next steps:
- We merge the
update_pudl_dependency
branch intodevelopment
once that is done - We close this PR and create a new branch off of development, and copy over
lint.yml
andpyproject.toml
and then apply all the linting - We merge all the formatting changes in, and then continue with our refactoring.
Let's merge |
@grgmiller , the branch is rebased onto the latest |
Purpose
Format existing Python files using
ruff
. Use ruff to automate and standardize formatting. Rules are listed in the newly created pyproject.toml. The configuration for formatting are the same asblack
. A GitHub workflow (Lint) is created to check that python files and notebooks are well formatted on push and pr (if not already triggered by push).What the code is doing
N/A
Testing
N/A
Where to look
Usage Example/Visuals
The following instances have been formated/linted manually (not fixable by
ruff
):Review estimate
5min
Future work
Do we want to enforce W501 for comments, docstrings and strings? If set it generates around 1000 violations
Checklist
black