Skip to content
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: Streamline cast_to() into correct type #864

Merged
merged 1 commit into from
Mar 27, 2025

Conversation

yermulnik
Copy link
Collaborator

Follow-up for #863 to correct cast_to() cast type for the string arg from bool to str.

@Copilot Copilot bot review requested due to automatic review settings March 26, 2025 21:13
Copy link

coderabbitai bot commented Mar 26, 2025

📝 Walkthrough

Summary by CodeRabbit

  • Refactor
    • Adjusted how command arguments are processed to ensure destination values are interpreted accurately, supporting reliable execution of commands.

Walkthrough

The update revises the type casting in the invoke_cli_app function within the Terraform docs replacement script. Instead of converting the dest argument to a boolean, the new change casts it to a string. This adjustment affects how the command is constructed for execution via subprocess.check_call, ensuring that the argument is processed as text. No modifications were made to any exported or public entities.

Changes

File Change Summary
src/.../terraform_docs_replace.py Updated the invoke_cli_app function by changing the type cast for the dest argument from bool to str.

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4366a73 and 4f44890.

📒 Files selected for processing (1)
  • src/pre_commit_terraform/terraform_docs_replace.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: 🧪 Tests / pytest@🐍3.9@macos-14
  • 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.11@windows-2025
  • GitHub Check: 🧪 Tests / pytest@🐍3.10@windows-2025
  • GitHub Check: pre-commit
🔇 Additional comments (1)
src/pre_commit_terraform/terraform_docs_replace.py (1)

81-81: Good correction on type casting.

Changing from cast_to('bool', parsed_cli_args.dest) to cast_to('str', parsed_cli_args.dest) is correct since dest represents a file path (defaulting to "README.md") and is used in string formatting. Casting it to a boolean was inconsistent with its usage in the code.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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 generate docstrings to generate docstrings for this 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

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR streamlines the type conversion for the "dest" argument by updating the cast type from bool to str.

  • Update the cast_to() call to use "str" instead of "bool"
  • Ensure the destination argument is correctly interpreted as a string

@yermulnik yermulnik requested a review from Copilot March 26, 2025 21:13
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR corrects the cast type in the call to cast_to(), updating the second argument from a boolean to a string as intended in the follow-up for #863.

  • Update cast type in the dest argument from 'bool' to 'str'
  • Ensure proper casting of the destination parameter in terraform_docs_replace.py

Copy link

codecov bot commented Mar 26, 2025

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 98.44%. Comparing base (4366a73) to head (4f44890).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/pre_commit_terraform/terraform_docs_replace.py 0.00% 1 Missing ⚠️

❌ Your patch status has failed because the patch coverage (0.00%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #864   +/-   ##
=======================================
  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% <0.00%> (ø)
MyPy 91.43% <0.00%> (ø)
OS-Linux 94.71% <0.00%> (ø)
OS-Windows 100.00% <ø> (ø)
OS-macOS 100.00% <ø> (ø)
Py-3.10.11 100.00% <ø> (ø)
Py-3.10.16 100.00% <ø> (ø)
Py-3.11.11 100.00% <ø> (ø)
Py-3.11.9 100.00% <ø> (ø)
Py-3.12.9 100.00% <ø> (ø)
Py-3.13.2 98.44% <0.00%> (ø)
Py-3.9.13 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% <0.00%> (ø)
VM-windows-2025 100.00% <ø> (ø)
pytest 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.

@@ -78,7 +78,7 @@ def invoke_cli_app(parsed_cli_args: Namespace) -> ReturnCodeType:
'>',
'./{dir}/{dest}'.format(
dir=dir,
dest=cast_to('bool', parsed_cli_args.dest),
dest=cast_to('str', parsed_cli_args.dest),
Copy link
Collaborator

Choose a reason for hiding this comment

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

They are both not covered by tests, so we can ignore codecov violations, as it's a deprecated hook anyway

image

@MaxymVlasov MaxymVlasov merged commit 9017b56 into master Mar 27, 2025
45 of 47 checks passed
@MaxymVlasov MaxymVlasov deleted the fix/cast_to_correctly branch March 27, 2025 12:45
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.

2 participants