-
Notifications
You must be signed in to change notification settings - Fork 7
[CI] Linter and formatter #24
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
base: main
Are you sure you want to change the base?
Conversation
Adds 'ruff' as Python linter and code formatter and 'pre-commit' for easy rules application both locally and in CI. New lint CI workflow is also added. The formatting tools are added as optional dependencies. They can be installed using: uv sync --extra dev-tools
|
The PR is split into two commits to make reviewing simpler. Current lint config is a simple opinionated collection of rules. |
|
If a PR fails on formatting, is there an actionable thing for developers to do to fix the formatting without having to patch by hand every difference? |
Would be great to set it up as on llvm-project, e.g. llvm/llvm-project#146732 (comment) where a Github action comments something like and then on further revisions the comment is edited to become: Just need to find the right Github workflows to copy (and appropriately massage) from llvm-project/.github. |
|
On the topic of copying from llvm-project: I would prefer if we also just keep to whichever code style is being enforced upstream. Just need to dig around a bit to find the right files that specify it. |
| dev_tools = [ | ||
| "pre-commit", | ||
| "ruff==0.14.5" | ||
| ] |
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.
As I now have more familiarity with pyproject.toml and uv than I would like: https://docs.astral.sh/uv/concepts/projects/dependencies/#development-dependencies says we should put "optional" dependencies which are "for development only" under the [dependency-groups] section (rather than [project.optional-dependencies]). See https://github.com/llvm/lighthouse/pull/22/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711R9-R13 as an example.
My take is that the main difference whether the "optional group" can be specified as an optional "extra" upon pip-installing. That is, whether pip install lighthouse[dev_toots] would be the right thing to support.
Note that this changes the installation syntax from ... --extra dev_tools to ... --group dev_tools.
Adds 'ruff' as Python linter and code formatter, and 'pre-commit' for easy rules application both locally and in CI.
New lint CI workflow is also added.
The formatting tools are added as optional dependencies.
They can be installed using:
uv sync --extra dev-tools
and locally run with:
pre-commit run --all-files