Skip to content

docs: document an accidental (sorry) recent breaking change in type checking compatibility of Python scripts, in favor of a clean and robust new syntax#4116

Merged
johanneskoester merged 5 commits intomainfrom
dbg/snakemake-type-check
Mar 19, 2026
Merged

docs: document an accidental (sorry) recent breaking change in type checking compatibility of Python scripts, in favor of a clean and robust new syntax#4116
johanneskoester merged 5 commits intomainfrom
dbg/snakemake-type-check

Conversation

@johanneskoester
Copy link
Copy Markdown
Contributor

@johanneskoester johanneskoester commented Mar 18, 2026

QC

  • The PR contains a test case for the changes or the changes are already covered by an existing test case.
  • 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).
  • I, as a human being, have checked each line of code in this pull request

AI-assistance disclosure

I used AI assistance for:

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Summary by CodeRabbit

  • Chores

    • Reduced the module's public import surface and adjusted internal type annotations to streamline exports; no runtime behavior changes.
  • Tests

    • Added an end-to-end test and a simple sample workflow that runs a script and verifies the expected "Hello world!" output.
  • Documentation

    • Updated the Python-scripts example to show a type-checking-safe import pattern.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 18, 2026

📝 Walkthrough

Walkthrough

Reduced the public import surface of src/snakemake/script/__init__.py, added a test scenario tests/test_script_import_snakemake_obj (Snakefile, script, expected output) to validate script import/usage, and introduced a module-level snakemake annotation in src/snakemake/io/container.py. No runtime control-flow changes.

Changes

Cohort / File(s) Summary
Script module export cleanup
src/snakemake/script/__init__.py
Removed several public imports: Dict, Optional, TypeVar, Union (from typing); PathLike (from snakemake.io.container); sourcecache (top-level snakemake); and get_report_id (snakemake.common). Export surface reduced; behavior unchanged.
New test scenario — files
tests/tests.py, tests/test_script_import_snakemake_obj/Snakefile, tests/test_script_import_snakemake_obj/script.py, tests/test_script_import_snakemake_obj/expected-results/test.txt
Added test_script_import_snakemake_obj(); new Snakefile rule runs script.py which writes Hello world! to test.txt. Expected output file added.
Docs update (example snippet)
docs/snakefiles/rules.rst
Replaced direct example import with a TYPE_CHECKING conditional import pattern for typed snakemake usage in Python script examples. Documentation-only change.
Container module annotation
src/snakemake/io/container.py
Added module-level type annotation snakemake: Snakemake, introducing a publicly declared name for typing; no runtime logic changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes: documenting a breaking change in type checking compatibility for Python scripts with a new recommended syntax.
Description check ✅ Passed The description follows the required template with all QC checkboxes completed and AI-assistance disclosure section included, though lacking detailed context about the breaking change.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dbg/snakemake-type-check
📝 Coding Plan
  • Generate coding plan for human review comments

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@johanneskoester johanneskoester changed the title Dbg/snakemake-type-check chore: testing type-checking compatibility for snakemake object in scripts Mar 18, 2026
@johanneskoester johanneskoester changed the title chore: testing type-checking compatibility for snakemake object in scripts docs: document an accidental (sorry) recent breaking change in type checking compatibility of Python scripts, in favor of a clean and robust new syntax Mar 19, 2026
@johanneskoester johanneskoester merged commit 013bc43 into main Mar 19, 2026
63 checks passed
@johanneskoester johanneskoester deleted the dbg/snakemake-type-check branch March 19, 2026 12:41
johanneskoester pushed a commit that referenced this pull request Mar 24, 2026
🤖 I have created a release *beep* *boop*
---


##
[9.17.3](v9.17.2...v9.17.3)
(2026-03-24)


### Bug Fixes

* add curl when containerize with wrapper
([#4115](#4115))
([44979e4](44979e4))
* ensure proper wrapper prefix is passed to CWL and shown in wrapper
error messages
([#4121](#4121))
([11b6f29](11b6f29))
* ensure that strings that purely contain integers or floats (e.g. "42")
remain strings when parsing profiles
([#4119](#4119))
([3ca08e1](3ca08e1))
* incorrect highlighting in HTML report
([#4120](#4120))
([1ef224d](1ef224d))


### Documentation

* document an accidental (sorry) recent breaking change in type checking
compatibility of Python scripts, in favor of a clean and robust new
syntax ([#4116](#4116))
([013bc43](013bc43))
* Rework tutorial
([#4068](#4068))
([4bba4a9](4bba4a9))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

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

## Summary by CodeRabbit

* **Chores**
  * Released version 9.17.3

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

1 participant