-
-
Notifications
You must be signed in to change notification settings - Fork 562
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
chore(linters): Introduce ruff and fix issues #831
base: master
Are you sure you want to change the base?
Conversation
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis pull request introduces a new pre-commit configuration for Python linting by integrating Ruff as both a linter and formatter. A new Changes
Sequence Diagram(s)sequenceDiagram
participant Dev as Developer
participant Git as Git
participant PC as Pre-commit Config
participant Ruff as Ruff Linter
participant Formatter as Ruff Formatter
Dev->>Git: Initiates commit
Git->>PC: Trigger pre-commit hooks
PC->>Ruff: Run "ruff" hook with --fix
Ruff-->>PC: Return linting and fix results
PC->>Formatter: Run "ruff-format" hook (skip excluded files)
Formatter-->>PC: Return formatting results
PC-->>Git: Proceed with commit if checks pass
sequenceDiagram
participant User as User
participant ArgParser as Argument Parser
participant CLI as CLI Application
participant ErrHnd as Error Handler
User->>ArgParser: Provide CLI arguments
ArgParser-->>CLI: Return parsed arguments
CLI->>CLI: Execute invoke_cli_app
alt Error Occurs
CLI->>ErrHnd: Print error message (with # noqa comment)
ErrHnd-->>CLI: Raise PreCommitTerraformExit
CLI-->>User: Return exit code
else Successful Execution
CLI-->>User: Return success code
end
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
Note 🎁 Summarized by CodeRabbit FreeYour organization has reached its limit of developer seats under the Pro Plan. For new users, CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please add seats to your subscription by visiting https://app.coderabbit.ai/login.If you believe this is a mistake and have available seats, please assign one to the pull request author through the subscription management page using the link above. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #831 +/- ##
=======================================
Coverage 98.44% 98.44%
=======================================
Files 28 28
Lines 578 578
Branches 17 17
=======================================
Hits 569 569
Misses 9 9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
tests/pytest/_cli_test.py
Outdated
@@ -65,35 +64,37 @@ def invoke_cli_app(self, parsed_cli_args: Namespace) -> ReturnCodeType: | |||
[CustomCmdStub()], | |||
) | |||
|
|||
assert ReturnCode.ERROR == invoke_cli_app(['sentinel']) |
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.
Urgh..
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.
lol. Didn't know that ruff able to replace code in this way
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.
Yep, some of the Ruff's linting rules also support autofixing feature. This is what happens when you pass --fix
. It's fine, just keep it separate.
unrelated is a separate PR. blame ignore is a separate PR. Plus I noticed reshuffling logic which is another one. So it's like 6 PRs. |
Also, plan for adding https://wemake-python-styleguide.rtfd.io on top after all this. |
from subprocess import CalledProcessError | ||
from argparse import ArgumentParser | ||
from argparse import Namespace | ||
from subprocess import CalledProcessError # noqa: S404. We invoke cli tools |
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.
Subprocess interaction should probably be quarantined in a dedicated module where these noqas would be allowed and nowhere else. That module should implement wrappers that the rest of the project would call. This design allows keeping all potentially dangerous code in one place that you can be extra careful about.
5425111
to
209b9dd
Compare
4f66e0f
to
f74ef59
Compare
TBD:
After @webknjaz will approve config, split to 4 PRs:
git blame
to s.2