fix: Unclear handling of params overriding with inheritance#3624
Conversation
📝 Walkthrough""" WalkthroughA conditional check was added to safely unpack rule parameters in Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Snakemake
participant RuleInfo
User->>Snakemake: Run workflow with parent/child rule inheritance
Snakemake->>RuleInfo: Initialize rule info for parent/child
RuleInfo->>RuleInfo: Unpack params with conditional check
RuleInfo-->>Snakemake: Provide parameters (handles None safely)
Snakemake->>Snakemake: Execute rules with inherited/overridden params
Snakemake->>User: Output result file
Assessment against linked issues
Assessment against linked issues: Out-of-scope changesNo out-of-scope changes found. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (35)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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
🧹 Nitpick comments (3)
tests/test_params_empty_inherit/expected-results/test.txt (1)
1-1: Consider adding a trailing newline for POSIX-compatibilityMany text-processing tools (e.g.
cat,grep) assume files end with a newline.
It’s harmless here, but appending\navoids surprises when these files are inspected or concatenated.src/snakemake/ruleinfo.py (1)
79-83: Robust fix – unwrapparamsonly when notNone👍 The guard elegantly prevents
ValueErrorwhen the parent rule lacks aparamsblock.
Small nit: using{}rather thandict()is marginally faster and matches surrounding style.-else ((), dict()) +else ((), {})🧰 Tools
🪛 Pylint (3.3.7)
[refactor] 82-82: Consider using '{}' instead of a call to 'dict'.
(R1735)
tests/test_params_empty_inherit/Snakefile (1)
5-9: Parent rule lacks explicitoutput: could confuse future maintenance
output[0]is used, yet the rule declares nooutput:section.
While the test never invokesparentdirectly, adding a dummy output (or marking the rule asnorun: True) clarifies intent and prevents accidental execution.rule parent: - run: + output: + "dummy_placeholder.txt" + run: with open(output[0], "w") as f: f.write(params.a)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/snakemake/ruleinfo.py(1 hunks)tests/test_params_empty_inherit/Snakefile(1 hunks)tests/test_params_empty_inherit/expected-results/test.txt(1 hunks)tests/tests.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.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 `s...
**/*.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.
src/snakemake/ruleinfo.pytests/tests.py
🧬 Code Graph Analysis (1)
tests/tests.py (1)
tests/common.py (2)
run(151-495)dpath(32-35)
🪛 Pylint (3.3.7)
src/snakemake/ruleinfo.py
[refactor] 82-82: Consider using '{}' instead of a call to 'dict'.
(R1735)
⏰ Context from checks skipped due to timeout of 90000ms (36)
- GitHub Check: tests (9, ubuntu-latest, py312)
- GitHub Check: tests (7, ubuntu-latest, py311)
- GitHub Check: tests (10, ubuntu-latest, py312)
- GitHub Check: tests (9, ubuntu-latest, py311)
- GitHub Check: tests (8, ubuntu-latest, py312)
- GitHub Check: tests (10, ubuntu-latest, py311)
- GitHub Check: tests (9, windows-latest, py312)
- GitHub Check: tests (10, windows-latest, py312)
- GitHub Check: tests (7, ubuntu-latest, py312)
- GitHub Check: tests (9, macos-latest, py312)
- GitHub Check: tests (6, ubuntu-latest, py312)
- GitHub Check: tests (5, ubuntu-latest, py311)
- GitHub Check: tests (8, windows-latest, py312)
- GitHub Check: tests (7, macos-latest, py312)
- GitHub Check: tests (8, ubuntu-latest, py311)
- GitHub Check: tests (5, ubuntu-latest, py312)
- GitHub Check: tests (5, windows-latest, py312)
- GitHub Check: tests (6, ubuntu-latest, py311)
- GitHub Check: tests (7, windows-latest, py312)
- GitHub Check: tests (2, ubuntu-latest, py312)
- GitHub Check: tests (4, windows-latest, py312)
- GitHub Check: tests (4, ubuntu-latest, py312)
- GitHub Check: tests (2, macos-latest, py312)
- GitHub Check: tests (2, windows-latest, py312)
- GitHub Check: tests (6, windows-latest, py312)
- GitHub Check: tests (3, windows-latest, py312)
- GitHub Check: tests (4, macos-latest, py312)
- GitHub Check: tests (2, ubuntu-latest, py311)
- GitHub Check: tests (1, ubuntu-latest, py312)
- GitHub Check: tests (3, ubuntu-latest, py312)
- GitHub Check: tests (1, windows-latest, py312)
- GitHub Check: tests (1, ubuntu-latest, py311)
- GitHub Check: tests (3, ubuntu-latest, py311)
- GitHub Check: tests (4, ubuntu-latest, py311)
- GitHub Check: tests (1, macos-latest, py312)
- GitHub Check: apidocs
🔇 Additional comments (2)
tests/tests.py (1)
2473-2476: Test registration looks good – please ensure isolationThe new test simply delegates to
run(...), which is fine.
Verify that the directory nametest_params_empty_inheritis unique (it is) and that no global state (e.g. env vars) leaks from preceding tests.tests/test_params_empty_inherit/Snakefile (1)
10-14: Override block is clear – no issues
use rule ... with:correctly overrides both output and params; newfound bug is covered.
### Description Follow-up change on merged PR #3624 , inspired by suggested PR #3496 (probs to @Hocnonsense ). ### QC * [x] The PR contains a test case for the changes or the changes are already covered by an existing test case. * [x] The documentation (`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). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved handling of rule parameters to prevent errors when parameters are missing. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
🤖 I have created a release *beep* *boop* --- ## [9.6.0](v9.5.1...v9.6.0) (2025-06-16) ### Features * Prefer papermill to nbconvert ([#2857](#2857)) ([4263b03](4263b03)) ### Bug Fixes * DeprecationWarning when using snakemake.utils.validate ([#3420](#3420)) ([cf72427](cf72427)) * display group jobs on dryrun ([#3435](#3435)) ([3bebef4](3bebef4)) * expandvars for special profile keys ([#3597](#3597)) ([4020188](4020188)) * fix bug causing --precommand to not being executed before each remote job ([#3625](#3625)) ([e59d125](e59d125)) * improved toggle switch behavior in reports ([#3623](#3623)) ([0c4bd23](0c4bd23)) * pass envvars defined via the envvars directive to remote jobs ([#3626](#3626)) ([d4890b4](d4890b4)) * remove wms arg, update logging cli docs ([#3622](#3622)) ([3a9a5ac](3a9a5ac)) * typo in CondaEnvDirSpec.__eq__ (issue [#3192](#3192)) ([#3613](#3613)) ([f4c107f](f4c107f)) * Unclear handling of params overriding with inheritance ([#3624](#3624)) ([077ac4a](077ac4a)) ### Documentation * Added snakemake command to execute the rule plot_with_python ([#3608](#3608)) ([bd99c11](bd99c11)) * Updated Reporting Section of The Tutorial(Interaction, Visualization, and Reporting with Snakemake) ([#3606](#3606)) ([91e90ba](91e90ba)) * Updated Requirement Section of The Tutorial With Warning of Not Installing The Tools Manually ([#3607](#3607)) ([3bd114b](3bd114b)) * Updated Wrapper Version in Tutorial and Used Simple Rule For Consistency & Ease ([#3605](#3605)) ([b3bcc21](b3bcc21)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
…e#3624) ### Description Fixes snakemake#3570 : Overwriting params for rule inheritance did not work properly when the parent rule did not define a params directive at all. ### QC * [x] The PR contains a test case for the changes or the changes are already covered by an existing test case. * [x] The documentation (`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). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved handling of rule parameters to prevent errors when parameters are missing or set to None. - **Tests** - Added new tests to verify correct behavior when inheriting and overriding rule parameters. - Included expected output files to validate test results. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
### Description Follow-up change on merged PR snakemake#3624 , inspired by suggested PR snakemake#3496 (probs to @Hocnonsense ). ### QC * [x] The PR contains a test case for the changes or the changes are already covered by an existing test case. * [x] The documentation (`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). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved handling of rule parameters to prevent errors when parameters are missing. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
🤖 I have created a release *beep* *boop* --- ## [9.6.0](snakemake/snakemake@v9.5.1...v9.6.0) (2025-06-16) ### Features * Prefer papermill to nbconvert ([snakemake#2857](snakemake#2857)) ([4263b03](snakemake@4263b03)) ### Bug Fixes * DeprecationWarning when using snakemake.utils.validate ([snakemake#3420](snakemake#3420)) ([cf72427](snakemake@cf72427)) * display group jobs on dryrun ([snakemake#3435](snakemake#3435)) ([3bebef4](snakemake@3bebef4)) * expandvars for special profile keys ([snakemake#3597](snakemake#3597)) ([4020188](snakemake@4020188)) * fix bug causing --precommand to not being executed before each remote job ([snakemake#3625](snakemake#3625)) ([e59d125](snakemake@e59d125)) * improved toggle switch behavior in reports ([snakemake#3623](snakemake#3623)) ([0c4bd23](snakemake@0c4bd23)) * pass envvars defined via the envvars directive to remote jobs ([snakemake#3626](snakemake#3626)) ([d4890b4](snakemake@d4890b4)) * remove wms arg, update logging cli docs ([snakemake#3622](snakemake#3622)) ([3a9a5ac](snakemake@3a9a5ac)) * typo in CondaEnvDirSpec.__eq__ (issue [snakemake#3192](snakemake#3192)) ([snakemake#3613](snakemake#3613)) ([f4c107f](snakemake@f4c107f)) * Unclear handling of params overriding with inheritance ([snakemake#3624](snakemake#3624)) ([077ac4a](snakemake@077ac4a)) ### Documentation * Added snakemake command to execute the rule plot_with_python ([snakemake#3608](snakemake#3608)) ([bd99c11](snakemake@bd99c11)) * Updated Reporting Section of The Tutorial(Interaction, Visualization, and Reporting with Snakemake) ([snakemake#3606](snakemake#3606)) ([91e90ba](snakemake@91e90ba)) * Updated Requirement Section of The Tutorial With Warning of Not Installing The Tools Manually ([snakemake#3607](snakemake#3607)) ([3bd114b](snakemake@3bd114b)) * Updated Wrapper Version in Tutorial and Used Simple Rule For Consistency & Ease ([snakemake#3605](snakemake#3605)) ([b3bcc21](snakemake@b3bcc21)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Description
Fixes #3570 : Overwriting params for rule inheritance did not work properly when the parent rule did not define a params directive at all.
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
Tests