Skip to content

Comments

chore(linters): Apply ruff-format#861

Merged
MaxymVlasov merged 2 commits intomasterfrom
ruff_format
Mar 26, 2025
Merged

chore(linters): Apply ruff-format#861
MaxymVlasov merged 2 commits intomasterfrom
ruff_format

Conversation

@MaxymVlasov
Copy link
Collaborator

@MaxymVlasov MaxymVlasov commented Mar 25, 2025

Subset of #831

Result of run

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

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

coderabbitai bot commented Mar 25, 2025

📝 Walkthrough

Summary by CodeRabbit

  • Refactor/Style

    • Enhanced code formatting and parameter alignment across internal routines to improve readability and maintainability.
  • Tests

    • Standardized the formatting of test functions for clearer, more consistent organization.

Note: These improvements are internal and do not affect any end-user functionality or experience.

Walkthrough

The changes involve formatting updates across multiple modules and test files, focusing on improving code readability. This includes reformatting single-line statements into multi-line structures, aligning method signatures and class declarations, and refining conditional statements. Additionally, f-strings are introduced for string interpolation. These modifications do not alter the functionality or logic of the code.

Changes

File(s) Change Summary
src/pre_commit_terraform/_cli_parsing.py, src/pre_commit_terraform/_errors.py, src/pre_commit_terraform/_types.py Reformatted code for improved readability: multi-line parser addition, aligned class declaration, and vertically aligned method signatures without altering functionality.
src/pre_commit_terraform/terraform_docs_replace.py Enhanced formatting within functions by splitting argument definitions, refining conditional statements, and updating string interpolation to f-strings for better clarity.
tests/pytest/_cli_test.py, tests/pytest/terraform_docs_replace_test.py Adjusted formatting of function parameter lists, regex expressions, and tuple unpacking to enforce consistency in the test code.

📜 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 d5d1a66 and 04017df.

📒 Files selected for processing (1)
  • tests/pytest/terraform_docs_replace_test.py (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/pytest/terraform_docs_replace_test.py

Note

🎁 Summarized by CodeRabbit Free

Your 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.

🪧 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.

Copy link

@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 e5f4170 and 4f544c6.

📒 Files selected for processing (8)
  • src/pre_commit_terraform/__main__.py (1 hunks)
  • src/pre_commit_terraform/_cli.py (1 hunks)
  • src/pre_commit_terraform/_cli_parsing.py (1 hunks)
  • src/pre_commit_terraform/_errors.py (1 hunks)
  • src/pre_commit_terraform/_types.py (1 hunks)
  • src/pre_commit_terraform/terraform_docs_replace.py (3 hunks)
  • tests/pytest/_cli_test.py (3 hunks)
  • tests/pytest/terraform_docs_replace_test.py (6 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
tests/pytest/_cli_test.py (4)
src/pre_commit_terraform/_cli.py (1)
  • invoke_cli_app (16-53)
src/pre_commit_terraform/_types.py (2)
  • invoke_cli_app (26-28)
  • populate_argument_parser (20-24)
src/pre_commit_terraform/terraform_docs_replace.py (2)
  • invoke_cli_app (49-83)
  • populate_argument_parser (14-46)
src/pre_commit_terraform/_errors.py (2)
  • PreCommitTerraformBaseError (4-5)
  • PreCommitTerraformExit (15-16)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: 🧪 Tests / pytest@🐍3.9@windows-2025
  • GitHub Check: 🧪 Tests / pytest@🐍3.9@macos-14
  • 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@macos-14
  • GitHub Check: 🧪 Tests / pytest@🐍3.11@windows-2025
  • GitHub Check: 🧪 Tests / pytest@🐍3.10@windows-2025
  • GitHub Check: pre-commit
🔇 Additional comments (24)
src/pre_commit_terraform/__main__.py (1)

3-4: LGTM: Import statements have been split for better readability.

Separating imports into individual lines follows Python best practices and makes version control diffs cleaner.

src/pre_commit_terraform/_errors.py (1)

8-11: LGTM: Improved formatting of multi-line class inheritance.

The indentation style for multiple base classes is now more consistent and follows modern Python formatting practices.

src/pre_commit_terraform/_cli.py (1)

24-27: LGTM: Applied type cast fix with string literal.

The change from using the actual type to using a string literal follows the recommendation in the FIXME comment. This is a common approach for handling forward references and addressing circular import issues in type annotations.

src/pre_commit_terraform/_cli_parsing.py (1)

25-27: LGTM: Function call reformatted for better readability.

Breaking the function call into multiple lines with proper indentation and trailing commas improves code readability and makes future modifications easier.

src/pre_commit_terraform/_types.py (1)

20-22: Improved code readability with better method signature formatting.

The parameter formatting change enhances readability by placing each parameter on its own line, which is consistent with PEP 8 style guidelines for function signatures with multiple parameters.

tests/pytest/_cli_test.py (6)

5-11: Import organization improved and uncommented needed exception.

The import statements have been properly organized, and PreCommitTerraformExit is now correctly imported instead of being commented out, which is necessary since it's used in the test_app_exit function.


44-49: Improved parameter formatting in test function.

The parameter formatting enhances readability by placing each parameter on its own line, following PEP 8 style guidelines for function signatures with multiple parameters.


55-58: Consistent method signature formatting.

The parameter formatting in the test stub matches the formatting in the actual implementation, maintaining consistency throughout the codebase.


70-70: Assertion reordered to follow conventional pattern.

Changed from assert ReturnCode.ERROR == invoke_cli_app(['sentinel']) to assert invoke_cli_app(['sentinel']) == ReturnCode.ERROR, which follows the more common pattern of "actual == expected" in assertions.


76-79: Improved parameter formatting in test function.

Similar to the other test function, this formatting change enhances readability by placing each parameter on its own line.


85-88: Consistent method signature formatting.

The parameter formatting in the second test stub also matches the formatting in the actual implementation, maintaining consistency.

src/pre_commit_terraform/terraform_docs_replace.py (7)

20-24: Improved parameter formatting in add_argument call.

The parameter formatting enhances readability by placing each parameter on its own line, following consistent style guidelines.


25-30: Improved parameter formatting for deprecated argument.

The formatting has been improved while preserving the deprecated status of this argument.


31-35: Improved parameter formatting for argument definition.

The parameter formatting enhances readability by placing each parameter on its own line, following consistent style guidelines.


59-63: Enhanced type casting and condition readability.

The reformatted code explicitly casts parsed_cli_args.filenames to list[str] and places conditions on separate lines, improving readability.


71-71: Consistent type casting format.

Changed to use string literal in cast_to('bool', parsed_cli_args.sort) instead of a type hint for consistency.


74-78: Modernized string formatting with f-strings.

Replaced string concatenation with more readable f-strings, which is a recommended practice in modern Python.


79-79: Simplified command construction with string join.

Using ' '.join(procArgs) is cleaner than manual string concatenation for building the command string.

tests/pytest/terraform_docs_replace_test.py (6)

8-16: Improved import organization and explicit module reference.

The imports have been reorganized for clarity, and the subprocess module from terraform_docs_replace is now explicitly imported as replace_docs_subprocess_mod, which improves the readability of mocking calls later in the test.


29-30: Simplified regex pattern concatenation.

The multiline regex pattern has been consolidated into a single line with concatenation, which maintains the same functionality while being more compact.


87-87: Assertion reordered to follow conventional pattern.

Changed from assert ReturnCode.OK == invoke_cli_app(parsed_cli_args) to assert invoke_cli_app(parsed_cli_args) == ReturnCode.OK, which follows the more common pattern of "actual == expected" in assertions.


90-91: Improved list comprehension readability.

The list comprehension for extracting command arguments has been reformatted for better readability.


101-104: Improved parameter formatting in test function.

The parameter formatting enhances readability by placing each parameter on its own line, following consistent style guidelines across the codebase.


122-122: Assertion reordered to follow conventional pattern.

Similar to the other assertion change, this follows the more common "actual == expected" pattern in assertions.

@codecov
Copy link

codecov bot commented Mar 25, 2025

Codecov Report

Attention: Patch coverage is 89.47368% with 2 lines in your changes missing coverage. Please review.

Project coverage is 98.44%. Comparing base (e5f4170) to head (04017df).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/pre_commit_terraform/terraform_docs_replace.py 93.33% 1 Missing ⚠️
tests/pytest/terraform_docs_replace_test.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #861      +/-   ##
==========================================
+ Coverage   98.42%   98.44%   +0.01%     
==========================================
  Files          28       28              
  Lines         571      578       +7     
  Branches       17       17              
==========================================
+ Hits          562      569       +7     
  Misses          9        9              
Flag Coverage Δ
CI-GHA 98.44% <89.47%> (+0.01%) ⬆️
MyPy 91.30% <89.47%> (+0.24%) ⬆️
OS-Linux 94.68% <89.47%> (+0.09%) ⬆️
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% <89.47%> (+0.01%) ⬆️
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.30% <89.47%> (+0.24%) ⬆️
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.

Copy link
Contributor

@webknjaz webknjaz left a comment

Choose a reason for hiding this comment

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

You can merge this, IF this only includes output of ruff format and nothing else.

@MaxymVlasov MaxymVlasov changed the title chore(linters): Apply ruff autofixes chore(linters): Apply ruff-format autofixes Mar 26, 2025
@MaxymVlasov MaxymVlasov requested a review from webknjaz March 26, 2025 13:25
Copy link
Contributor

@webknjaz webknjaz left a comment

Choose a reason for hiding this comment

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

autofixes

LGTM, but drop this "fixes" thing. It doesn't contain fixes, only formatting.

@MaxymVlasov MaxymVlasov changed the title chore(linters): Apply ruff-format autofixes chore(linters): Apply ruff-format Mar 26, 2025
@MaxymVlasov MaxymVlasov marked this pull request as ready for review March 26, 2025 13:29
@MaxymVlasov MaxymVlasov requested a review from yermulnik March 26, 2025 13:29
@MaxymVlasov MaxymVlasov merged commit 23928fb into master Mar 26, 2025
50 of 52 checks passed
@MaxymVlasov MaxymVlasov deleted the ruff_format branch March 26, 2025 13:49
@webknjaz
Copy link
Contributor

@MaxymVlasov now, make a PR introducing this file https://github.com/ansible/awx-plugins/blob/55596a6/.git-blame-ignore-revs but replace the last line with a reference to 23928fb.

@antonbabenko
Copy link
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