Repository navigation
Output the required formatting changes #1216
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
Changes from all commits
375c654
a99623a
f4137f1
49baf64
360b81e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,11 @@ on: [push, pull_request] | |
| jobs: | ||
| ruff: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| MESSAGE: | | ||
| Your code is not formatted! | ||
| Please setup your development environment and run the formatting command. | ||
| https://icalendar.readthedocs.io/en/stable/contribute/development.html#code-format | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Set up Python | ||
|
|
@@ -15,10 +20,17 @@ jobs: | |
| python -m pip install --upgrade pip | ||
| pip install . --group formatting | ||
| - name: Run the ruff formatter to change files | ||
| run: ruff format --check . | ||
| - name: Run ruff checks on the files | ||
| run: ruff check --fix | ||
| run: ruff format . | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like automatic rewrites of PRs. Please don't do this.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not rewrite a PR. does not output anything.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You replaced that with: which most certainly rewrites the PR.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The next step will fail if the files have been formatted - not with a one-liner but with a more elaborate message for which a screenshot can be found in the PR head. Even if the topic is charged in the other PR, it is ok to ask questions for understanding. |
||
| - name: Fail if we detect any changes on the file system | ||
| run: | | ||
| git status | ||
| git diff --exit-code | ||
| if ! git diff --exit-code; then | ||
| echo "$MESSAGE" | ||
| exit 1; | ||
| fi | ||
| - name: Run ruff checks on the files | ||
| run: | | ||
| if ! ruff check; then | ||
| echo "$MESSAGE" | ||
| exit 1; | ||
| fi | ||
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.
Most projects in the ecosystem use the simpler standard pattern:
Adding
--output-format=githubto both gives inline PR annotations, which may be better UX than the git diff approach:The current
ruff format .+git diffapproach works and the diff is helpful, but it's non-standard. Worth considering whether the GitHub annotations would serve contributors better.Uh oh!
There was an error while loading. Please reload this page.
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.
Hm. Thanks for suggesting this.
I don't think that will help e.g. know that a newline should be added:
$ ruff format --check --output-format=github --preview . ::error title=Ruff (unformatted),file=/home/nicco/icalendar/src/icalendar/__init__.py,line=181,endLine=183::src/icalendar/__init__.py:181:1: unformatted: File would be reformatted ::error title=Ruff (unformatted),file=/home/nicco/icalendar/src/icalendar/parser/string.py,line=35,endLine=175::src/icalendar/parser/string.py:35:13: unformatted: File would be reformatted ::error title=Ruff (unformatted),file=/home/nicco/icalendar/src/icalendar/prop/categories.py,line=29,endLine=34::src/icalendar/prop/categories.py:29:26: unformatted: File would be reformatted ::error title=Ruff (unformatted),file=/home/nicco/icalendar/src/icalendar/prop/factory.py,line=114,endLine=214::src/icalendar/prop/factory.py:114:30: unformatted: File would be reformatted ::error title=Ruff (unformatted),file=/home/nicco/icalendar/src/icalendar/prop/image.py,line=66,endLine=72::src/icalendar/prop/image.py:66:23: unformatted: File would be reformatted ::error title=Ruff (unformatted),file=/home/nicco/icalendar/src/icalendar/prop/recur/frequency.py,line=18,endLine=28::src/icalendar/prop/recur/frequency.py:18:32: unformatted: File would be reformatted ::error title=Ruff (unformatted),file=/home/nicco/icalendar/src/icalendar/prop/recur/recur.py,line=138,endLine=158::src/icalendar/prop/recur/recur.py:138:26: unformatted: File would be reformatted ::error title=Ruff (unformatted),file=/home/nicco/icalendar/src/icalendar/prop/recur/weekday.py,line=49,endLine=59::src/icalendar/prop/recur/weekday.py:49:30: unformatted: File would be reformatted ::error title=Ruff (unformatted),file=/home/nicco/icalendar/src/icalendar/tests/attr/test_rdate.py,line=37,endLine=42::src/icalendar/tests/attr/test_rdate.py:37:22: unformatted: File would be reformatted ::error title=Ruff (unformatted),file=/home/nicco/icalendar/src/icalendar/tests/prop/test_unit.py,line=126,endLine=133::src/icalendar/tests/prop/test_unit.py:126:18: unformatted: File would be reformatted ::error title=Ruff (unformatted),file=/home/nicco/icalendar/src/icalendar/tests/prop/test_vPeriod.py,line=45,endLine=47::src/icalendar/tests/prop/test_vPeriod.py:45:17: unformatted: File would be reformatted ::error title=Ruff (unformatted),file=/home/nicco/icalendar/src/icalendar/tests/rfc_6350_vcard/test_vAdr.py,line=50,endLine=95::src/icalendar/tests/rfc_6350_vcard/test_vAdr.py:50:20: unformatted: File would be reformatted ::error title=Ruff (unformatted),file=/home/nicco/icalendar/src/icalendar/tests/rfc_7265_jcal/test_invalid_jcal.py,line=124,endLine=352::src/icalendar/tests/rfc_7265_jcal/test_invalid_jcal.py:124:29: unformatted: File would be reformatted ::error title=Ruff (unformatted),file=/home/nicco/icalendar/src/icalendar/tests/rfc_7265_jcal/test_section_3_6_values.py,line=112,endLine=119::src/icalendar/tests/rfc_7265_jcal/test_section_3_6_values.py:112:16: unformatted: File would be reformatted ::error title=Ruff (unformatted),file=/home/nicco/icalendar/src/icalendar/tests/test_cli_tool.py,line=43,col=17,endLine=43,endColumn=17::src/icalendar/tests/test_cli_tool.py:43:17: unformatted: File would be reformatted ::error title=Ruff (unformatted),file=/home/nicco/icalendar/src/icalendar/tests/test_icalendar.py,line=154,endLine=228::src/icalendar/tests/test_icalendar.py:154:49: unformatted: File would be reformatted ::error title=Ruff (unformatted),file=/home/nicco/icalendar/src/icalendar/tests/test_issue_821_stdin_parse.py,line=54,col=17,endLine=54,endColumn=17::src/icalendar/tests/test_issue_821_stdin_parse.py:54:17: unformatted: File would be reformatted ::error title=Ruff (unformatted),file=/home/nicco/icalendar/src/icalendar/tests/test_period.py,line=45,endLine=67::src/icalendar/tests/test_period.py:45:36: unformatted: File would be reformatted ::error title=Ruff (unformatted),file=/home/nicco/icalendar/src/icalendar/tests/test_property_params.py,line=26,endLine=64::src/icalendar/tests/test_property_params.py:26:24: unformatted: File would be reformatted ::error title=Ruff (unformatted),file=/home/nicco/icalendar/src/icalendar/tests/test_unit_cal.py,line=31,endLine=183::src/icalendar/tests/test_unit_cal.py:31:43: unformatted: File would be reformattedIf you have improvement ideas, could you open an issue for those?
test:
::error title=Ruff (unformatted),file=/home/nicco/icalendar/src/icalendar/tests/test_issue_821_stdin_parse.py,line=54,col=17,endLine=54,endColumn=17::src/icalendar/tests/test_issue_821_stdin_parse.py:54:17: unformatted: File would be reformatted