Skip to content

chore(linters): Fix ruff linter issues manually#866

Merged
MaxymVlasov merged 8 commits intomasterfrom
ruff_lint_manual
Apr 3, 2025
Merged

chore(linters): Fix ruff linter issues manually#866
MaxymVlasov merged 8 commits intomasterfrom
ruff_lint_manual

Conversation

@MaxymVlasov
Copy link
Copy Markdown
Collaborator

Description of your changes

Subset of #831

Run next and fix violations one by one

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
  rev: v0.8.4
  hooks:
  - id: ruff
    args:
      - --fix
  - id: ruff-format

and commit as separate commits

with same ruff.toml as in #831, except 2 last lines which enable ignore of deprecated hooks (https://github.com/antonbabenko/pre-commit-terraform/blob/948a36d52d36270c329028bd27f7a3e999c899ff/ruff.toml)

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 31, 2025

📝 Walkthrough

Summary by CodeRabbit

  • Documentation

    • Expanded CLI help documentation with clear details on output values and argument parsing to improve user guidance.
    • Adjusted inline warnings and naming for enhanced clarity in usage instructions.
  • Tests

    • Removed redundant testing and refined error message matching to ensure more robust validation of app exit behavior.

Walkthrough

The changes enhance the documentation in several CLI-related modules by updating and expanding function docstrings to clearly specify return types and function outputs. Additionally, variable names were refined for clarity, and minor formatting adjustments were applied. A commented-out test case was removed, and a regex string was updated to a raw string in one test file. No functional behavior is altered.

Changes

File(s) Change Summary
src/pre_commit_terraform/_cli.py
src/pre_commit_terraform/_cli_parsing.py
Updated function docstrings to explicitly include details about return types and function outputs.
src/pre_commit_terraform/terraform_docs_replace.py Added docstrings to functions (populate_argument_parser and invoke_cli_app), modified a warning message in invoke_cli_app, renamed variables (e.g., dirdirectory, procArgsproc_args), and adjusted the formatting of a subprocess call.
tests/pytest/_cli_test.py Removed a commented-out test case for the PreCommitTerraformExit exception and updated the regex string in the test_app_exit function from match='^sentinel$' to match=r'^sentinel$' to ensure proper interpretation by the regex engine.

Suggested reviewers

  • antonbabenko
  • webknjaz
  • yermulnik

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Free

📥 Commits

Reviewing files that changed from the base of the PR and between 9017b56 and 9e0bc95.

📒 Files selected for processing (4)
  • src/pre_commit_terraform/_cli.py (1 hunks)
  • src/pre_commit_terraform/_cli_parsing.py (1 hunks)
  • src/pre_commit_terraform/terraform_docs_replace.py (3 hunks)
  • tests/pytest/_cli_test.py (1 hunks)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@MaxymVlasov MaxymVlasov changed the title chore(linters): Manually fix ruff linter issues chore(linters): Fix ruff linter issues manually Mar 31, 2025
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9017b56 and 45a108c.

📒 Files selected for processing (4)
  • src/pre_commit_terraform/_cli.py (1 hunks)
  • src/pre_commit_terraform/_cli_parsing.py (1 hunks)
  • src/pre_commit_terraform/terraform_docs_replace.py (3 hunks)
  • tests/pytest/_cli_test.py (1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
tests/pytest/_cli_test.py (1)
src/pre_commit_terraform/_errors.py (1)
  • PreCommitTerraformExit (15-16)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: 🧪 Tests / pytest@🐍3.9@windows-2025
  • GitHub Check: 🧪 Tests / pytest@🐍3.9@macos-13
  • GitHub Check: 🧪 Tests / pytest@🐍3.13@windows-2025
  • GitHub Check: 🧪 Tests / pytest@🐍3.13@macos-14
  • GitHub Check: 🧪 Tests / pytest@🐍3.13@macos-13
  • GitHub Check: 🧪 Tests / pytest@🐍3.12@windows-2025
  • GitHub Check: 🧪 Tests / pytest@🐍3.12@macos-14
  • GitHub Check: 🧪 Tests / pytest@🐍3.11@windows-2025
  • GitHub Check: 🧪 Tests / pytest@🐍3.10@windows-2025
  • GitHub Check: pre-commit
🔇 Additional comments (7)
src/pre_commit_terraform/_cli.py (1)

21-23: Good docstring enhancement!

Adding the return type documentation improves the clarity and completeness of the function documentation, which aligns well with the PR's objective of fixing linter issues.

tests/pytest/_cli_test.py (1)

99-99: Good practice using raw string for regex pattern.

Converting the regular expression to a raw string (r'^sentinel$') is a best practice in Python, even when the pattern doesn't contain escape sequences. This change helps prevent potential issues with escape sequences in more complex patterns and improves code quality.

src/pre_commit_terraform/terraform_docs_replace.py (5)

15-15: Good docstring addition.

Adding a clear docstring for the function improves code documentation and readability.


51-55: Good docstring enhancement!

Adding a complete docstring with return type information improves the clarity and completeness of the function documentation.


75-75: Good variable rename to avoid shadowing built-in function.

Renaming the variable from dir to directory is a good practice as it avoids shadowing the built-in Python dir() function, which could lead to confusion or subtle bugs.


77-81: Improved variable naming convention and code structure.

Converting procArgs to proc_args follows Python's snake_case naming convention (PEP 8). The restructured code for building the command arguments is also more readable and maintainable.


84-88: Consistent variable naming in string formatting.

Updating the f-string and format string to use the renamed directory variable maintains consistency throughout the function.

Comment thread src/pre_commit_terraform/_cli_parsing.py Outdated
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.44%. Comparing base (9017b56) to head (9e0bc95).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #866   +/-   ##
=======================================
  Coverage   98.44%   98.44%           
=======================================
  Files          28       28           
  Lines         578      578           
  Branches       17       17           
=======================================
  Hits          569      569           
  Misses          9        9           
Flag Coverage Δ
CI-GHA 98.44% <100.00%> (ø)
MyPy 91.43% <100.00%> (ø)
OS-Linux 94.71% <100.00%> (ø)
OS-Windows 100.00% <100.00%> (ø)
OS-macOS 100.00% <ø> (ø)
Py-3.10.11 100.00% <100.00%> (ø)
Py-3.10.16 100.00% <ø> (ø)
Py-3.11.11 100.00% <ø> (ø)
Py-3.11.9 100.00% <100.00%> (ø)
Py-3.12.9 100.00% <100.00%> (ø)
Py-3.13.2 98.44% <100.00%> (ø)
Py-3.9.13 100.00% <100.00%> (ø)
Py-3.9.21 100.00% <ø> (ø)
VM-macos-13 100.00% <ø> (ø)
VM-macos-14 100.00% <ø> (ø)
VM-ubuntu-24.04 100.00% <ø> (ø)
VM-ubuntu-latest 91.43% <100.00%> (ø)
VM-windows-2025 100.00% <100.00%> (ø)
pytest 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MaxymVlasov MaxymVlasov marked this pull request as ready for review April 2, 2025 23:57
@MaxymVlasov MaxymVlasov merged commit 8d38688 into master Apr 3, 2025
47 checks passed
@MaxymVlasov MaxymVlasov deleted the ruff_lint_manual branch April 3, 2025 12:55
@antonbabenko
Copy link
Copy Markdown
Owner

This PR is included in version 1.98.1 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants