Skip to content

fix: problem with spaces in path (by quoting CLI args)#79

Merged
johanneskoester merged 1 commit intosnakemake:mainfrom
kjohnsen:main
Dec 21, 2024
Merged

fix: problem with spaces in path (by quoting CLI args)#79
johanneskoester merged 1 commit intosnakemake:mainfrom
kjohnsen:main

Conversation

@kjohnsen
Copy link
Copy Markdown
Contributor

@kjohnsen kjohnsen commented Dec 20, 2024

Goes together with snakemake/snakemake#3236
Fixes snakemake/snakemake#3235

I don't know if adding quoting of CLI args by default will break anything—I didn't run the whole test suite locally.

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of the quote parameter in CLI argument formatting for consistent behavior across single and iterable values.
  • Chores

    • Maintained existing functionality and error handling in related utility functions without introducing new changes.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Dec 20, 2024

📝 Walkthrough

Walkthrough

The pull request introduces modifications to the format_cli_pos_arg function in the utils.py file, specifically improving the handling of the quote parameter. The changes ensure consistent quoting behavior when processing both single and iterable values for command-line interface (CLI) arguments. The core functionality of the utility module remains unchanged, with the primary focus on refining argument formatting logic.

Changes

File Change Summary
snakemake_interface_executor_plugins/utils.py Modified format_cli_pos_arg function to consistently pass quote parameter to format_cli_value for both single and iterable values

The changes are primarily focused on improving the argument formatting mechanism, ensuring that quoting is applied consistently across different types of input values. No new functions were added or removed, and the overall module structure remains the same.

Note: Since the changes are relatively straightforward and do not introduce a complex new flow or feature, a sequence diagram is not necessary in this case.

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between adc8363 and a11a28a.

📒 Files selected for processing (1)
  • snakemake_interface_executor_plugins/utils.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
snakemake_interface_executor_plugins/utils.py (1)

Pattern **/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of the self argument of methods.
Do not suggest type annotation of the cls argument of classmethods.
Do not suggest return type annotation if a function or method does not contain a return statement.

🔇 Additional comments (2)
snakemake_interface_executor_plugins/utils.py (2)

45-45: LGTM! Consistent quoting behavior for non-iterable values.

The change correctly propagates the quote parameter to format_cli_value, ensuring consistent quoting behavior for non-iterable CLI arguments.


48-48: LGTM! Consistent quoting behavior for iterable values.

The change correctly propagates the quote parameter to format_cli_value for each value in the iterable, maintaining consistent quoting behavior across all CLI arguments.

Let's verify the impact on existing callers:

✅ Verification successful

Change is safe and consistent with test cases

The verification confirms that the change is safe and well-tested:

  • The test cases in tests/tests.py cover various quoting scenarios including lists (test_format_cli_arg_list), showing the expected behavior for iterable values
  • The format_cli_value function is used consistently throughout the codebase, with the quote parameter being properly propagated in all cases
  • The change maintains consistency with the existing behavior while ensuring proper quoting for each element in iterable values
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all calls to format_cli_pos_arg to ensure they handle the quote parameter correctly

# Search for function calls with their context
rg -A 3 "format_cli_pos_arg\(" --type py

# Search for potential test cases
rg -l "test.*format_cli" --type py

Length of output: 752


Script:

#!/bin/bash
# Let's examine the test file to understand the expected behavior
cat tests/tests.py

# Also check for any other usages of format_cli_value
rg "format_cli_value" --type py -A 3

Length of output: 3424


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@kjohnsen kjohnsen changed the title quote CLI args fix: problem with spaces in path (by quoting CLI args) Dec 20, 2024
@johanneskoester johanneskoester merged commit 404cd30 into snakemake:main Dec 21, 2024
johanneskoester added a commit to snakemake/snakemake that referenced this pull request Dec 21, 2024
Fixes #3235 
Goes together with
snakemake/snakemake-interface-executor-plugins#79
This PR updates tests to catch the bug (should break at least
`test_path_with_spaces` and `test_with_parentheses` and
snakemake/snakemake-interface-executor-plugins#79
actually fixes it

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Summary by CodeRabbit

- **New Features**
- Introduced a new rule that generates an output file with a predefined
string.
- **Tests**
	- Added a test case to verify the handling of paths containing spaces.
- Enhanced temporary directory naming for clarity during test execution.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Johannes Köster <johannes.koester@tu-dortmund.de>
Co-authored-by: Johannes Koester <johannes.koester@uni-due.de>
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.

"Snakefile not found" when path contains a space, using run directive

2 participants