style: add typing to pass mypy and pyright in snakemake.io.__init__ and snakemake.io.container#4082
style: add typing to pass mypy and pyright in snakemake.io.__init__ and snakemake.io.container#4082johanneskoester merged 9 commits intomainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughTightened and modernized type annotations in io modules: added a TypeVar and Coroutine typing for Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment Tip Flake8 can be used to improve the quality of Python code reviews.Flake8 is a Python linter that wraps PyFlakes, pycodestyle and Ned Batchelder's McCabe script. To configure Flake8, add a '.flake8' or 'setup.cfg' file to your project root. See Flake8 Documentation for more details. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/snakemake/io/__init__.py`:
- Around line 791-799: In the except MissingOutputException block, preserve the
original exception context by chaining the new WorkflowError from the caught
exception (use "raise WorkflowError(... ) from e") and avoid shadowing the
built-in by renaming the local variable dir to dirpath (update the assignment
"dir = _file if self.is_directory else os.path.dirname(_file)" to use dirpath).
Keep references to _file, is_directory, and the is_callable(self._file) check
unchanged and ensure the new WorkflowError is raised using "from e".
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 247f5fa0-2360-4902-92cb-da773ec49db1
📒 Files selected for processing (2)
src/snakemake/io/__init__.pysrc/snakemake/io/container.py
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/snakemake/io/__init__.py`:
- Around line 461-463: Fix the misspelling in the inline comment inside the
storage_object method: change "silance" to "silence" in the comment that starts
with "assume that all .storage_object is called after .is_storage check..." near
the storage_object function (which returns get_flag_value(self._file,
"storage_object")). Ensure only the comment text is updated and no code behavior
is changed.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 567b8dff-42a1-46fa-8cf4-0193779e24bd
📒 Files selected for processing (1)
src/snakemake/io/__init__.py
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/snakemake/io/__init__.py (1)
1046-1046: Usecollections.abc.Setannotation to match immutable default value.Line 1046 annotates
consider_localasSet[_IOFile](mutable protocol) but defaults tofrozenset()(immutable), requiring# type: ignore[assignment]. Since this parameter is used only for membership checks, annotate it ascollections.abc.Set[_IOFile]to properly reflect its immutable usage and eliminate the ignore comment.♻️ Proposed typing-only adjustment
- consider_local: Set[_IOFile] = frozenset(), # type: ignore[assignment] + consider_local: collections.abc.Set[_IOFile] = frozenset(),🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/snakemake/io/__init__.py` at line 1046, The parameter annotation for consider_local currently uses typing.Set[_IOFile] but the default is an immutable frozenset() and the value is only used for membership checks; change the annotation to collections.abc.Set[_IOFile] (import collections.abc as needed) on the function or variable where consider_local is declared and remove the trailing "# type: ignore[assignment]" so the type matches the immutable default and eliminates the ignore; reference the consider_local parameter and the _IOFile element type when making this edit.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/snakemake/io/__init__.py`:
- Line 1046: The parameter annotation for consider_local currently uses
typing.Set[_IOFile] but the default is an immutable frozenset() and the value is
only used for membership checks; change the annotation to
collections.abc.Set[_IOFile] (import collections.abc as needed) on the function
or variable where consider_local is declared and remove the trailing "# type:
ignore[assignment]" so the type matches the immutable default and eliminates the
ignore; reference the consider_local parameter and the _IOFile element type when
making this edit.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6b56a6f4-c7d2-459c-aad7-0567059f9fd6
📒 Files selected for processing (1)
src/snakemake/io/__init__.py
Co-authored-by: Johannes Köster <johannes.koester@tu-dortmund.de>
fix bugs introduced in #4032
QC
Summary by CodeRabbit
Bug Fixes
New Features
Chores