fix: better error handling in evaluate function#3129
Conversation
WalkthroughThe changes in this pull request focus on enhancing the error handling of the Changes
Possibly related PRs
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? 🪧 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
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
snakemake/ioutils.py (1)
238-245: Approve changes with suggestions for further improvementsThe error handling improvements in the
evaluatefunction are good. They provide more context when an error occurs, making debugging easier. Here are some suggestions to further enhance the implementation:
- Use
raise ... from efor better exception chaining:except Exception as e: raise WorkflowError( f"Failed to evaluate expression {expr!r} with wildcards {wildcards!r}. " f"Formatted expression: {formatted!r}" ) from e
- Consider using an f-string for
formattedfor better readability:formatted = f"{expr}".format(**{w: repr(v) for w, v in wildcards.items()})
- Add a return type hint for the inner function:
def inner(wildcards) -> Any:Would you like me to implement these changes?
🧰 Tools
🪛 Ruff
242-245: Within an
exceptclause, raise exceptions withraise ... from errorraise ... from Noneto distinguish them from errors in exception handling(B904)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- snakemake/ioutils.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
snakemake/ioutils.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 theselfargument of methods.
Do not suggest type annotation of theclsargument of classmethods.
Do not suggest return type annotation if a function or method does not contain areturnstatement.
🪛 Ruff
snakemake/ioutils.py
242-245: Within an
exceptclause, raise exceptions withraise ... from errorraise ... from Noneto distinguish them from errors in exception handling(B904)
|
🤖 I have created a release *beep* *boop* --- ## [8.21.0](v8.20.7...v8.21.0) (2024-10-12) ### Features * support for specifying conda envs as directories ([#3132](#3132)) ([c54c95d](c54c95d)) ### Bug Fixes * better error handling in evaluate function ([#3129](#3129)) ([04fb97f](04fb97f)) * notebook execution for apptainer ([#3131](#3131)) ([2e382c4](2e382c4)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>



QC
docs/) is updated to reflect the changes or this is not necessary (e.g. if the change does neither modify the language nor the behavior or functionalities of Snakemake).Summary by CodeRabbit
Bug Fixes
Chores