-
Notifications
You must be signed in to change notification settings - Fork 17
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
Clarify ruff functionality. #403
Conversation
{%- if 'ruff_lint' in enforce_style %} | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
# Ruff version. | ||
rev: v0.1.3 | ||
hooks: | ||
- id: ruff | ||
name: Format and lint code using ruff | ||
name: Lint code using ruff | ||
types_or: [ python, pyi, jupyter ] | ||
args: ["check"] | ||
{%- endif %} | ||
{%- if 'ruff_format' in enforce_style %} | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
# Ruff version. | ||
rev: v0.1.3 | ||
hooks: | ||
- id: ruff | ||
name: Format code using ruff | ||
types_or: [ python, pyi, jupyter ] | ||
args: ["format", "--check"] | ||
{%- endif %} |
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'm not sure why the hook's readme proposes to put hooks in this order. If we do this, the linter would fail for some bad formatting (for example long lines), before formatter runs. I suggest to swap the order, so formatter runs first and fixes some linting issues
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 I agree with the ruff folks on this one!
Since the pre-commit is mostly about warning, and not about fixing the changes, I'm a fan of the lint-first-then-format ordering. This would also alert sooner about "code smell" type problems, before alerting about more minor formatting issues.
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 point is that we can automatically fix formatting with the first hook, instead of fail
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'll move this discussion to a new issue. Thank you!
Change Description
Closes #395
Closes #384
Checklist
lincc-frameworks/python-project-template
repo and not a downstream one instead.