-
Notifications
You must be signed in to change notification settings - Fork 287
Adopt ruff formatter instead of black #1051
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
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #1051 +/- ##
==========================================
- Coverage 93.26% 89.59% -3.67%
==========================================
Files 104 106 +2
Lines 15814 16796 +982
Branches 35 35
==========================================
+ Hits 14749 15049 +300
- Misses 1058 1740 +682
Partials 7 7 see 8 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
CodSpeed Performance ReportMerging #1051 will improve performances by 14.35%Comparing Summary
Benchmarks breakdown
|
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.
Looks good overall - could you run locally to make sure all is working as expected? 👍 Thanks for the help!
Also, the test that's failing isn't related to your work, so don't worry about that.
Makefile
Outdated
$(black) | ||
$(ruff) --fix --exit-zero | ||
ruff format --check --diff $(sources) | ||
cargo fmt | ||
|
||
.PHONY: lint-python | ||
lint-python: | ||
$(ruff) | ||
$(black) --check --diff | ||
ruff --fix --exit-zero $(sources) |
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.
I think we'll want to do something like we did with pydantic
here:
https://github.com/pydantic/pydantic/blob/9868b456e4352558aa01217a6688b30554c6f290/Makefile#L26-L34
With a ruff --fix
and ruff format
call in the format
step and ruff
and ruff format check
in the lint step 👍
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.
Correct, lint should change anything.
Surely ruff format
should imply ruff --fix
?
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.
I think we should use both based on this: https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
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.
My thinking is there was some redundancy in the last PR.
As an example, a linter and formatter command under the linting step:
.PHONY: lint ## Lint python source files
lint: .pdm
pdm run ruff $(sources)
pdm run ruff format --check $(sources)
Nonetheless happy to make the modifications per your recommendation.
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.
Yeah, I think we're really using lint like a check
step and the format step like a fix
step. I'm making some changes to pytest-examples
right now that should iron out the details of which things we want to use where.
I'll get back to you on Monday with an answer about which we want to use here 👍
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.
Let's stick with the same pattern we're using in pydantic
for now 👍
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.
Done, let me know if anything else.
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.
Looks great to me, thanks!
Change Summary
[".github/workflows/ci.yml","Makefile", "pyproject.toml", "tests/requirements-linting.txt"]
Related issue number
closes #1048
Checklist
pydantic-core
(except for expected changes)