[fix] add additional sp_options arg to FastEMStreamController needed for base class StreamController#3422
Conversation
…for base class StreamController
There was a problem hiding this comment.
Pull request overview
This PR updates FastEMStreamController to accept and forward the sp_options argument so it remains compatible with the base StreamController initialization contract used by stream-bar creation code.
Changes:
- Add
sp_optionsparameter toFastEMStreamController.__init__. - Forward
sp_optionsthrough toStreamController.__init__viasuper().__init__(..., sp_options=sp_options).
📝 WalkthroughWalkthroughThe 🚥 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)
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 |
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/odemis/gui/cont/stream.py`:
- Around line 1384-1389: Add parameter and return type annotations to
FastEMStreamController.__init__: annotate stream_bar, stream, tab_data_model
with their concrete types used elsewhere (e.g., StreamBar, Stream,
TabDataModel), annotate show_panel as bool, view and sb_ctrl as Optional[...],
and sp_options as Optional[dict] (or Optional[Mapping[str, Any]]), and set the
return type to None. Also add a concise docstring to __init__ describing the
purpose of the constructor and each parameter (including defaults and
optionality) and any side effects (e.g., registering with stream_bar), matching
the project's docstring style.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 099ee25f-7704-4047-9c69-79e5d200c77d
📒 Files selected for processing (1)
src/odemis/gui/cont/stream.py
| def __init__(self, stream_bar, stream, tab_data_model, show_panel=True, view=None, | ||
| sb_ctrl=None): | ||
| sb_ctrl=None, sp_options=None): | ||
| super().__init__( | ||
| stream_bar=stream_bar, stream=stream, tab_data_model=tab_data_model, | ||
| show_panel=show_panel, view=view, sb_ctrl=sb_ctrl | ||
| show_panel=show_panel, view=view, sb_ctrl=sb_ctrl, sp_options=sp_options | ||
| ) |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify whether __init__ in FastEMStreamController has full annotations + docstring.
python - <<'PY'
import ast, pathlib
path = pathlib.Path("src/odemis/gui/cont/stream.py")
mod = ast.parse(path.read_text(encoding="utf-8"))
for node in mod.body:
if isinstance(node, ast.ClassDef) and node.name == "FastEMStreamController":
for fn in node.body:
if isinstance(fn, ast.FunctionDef) and fn.name == "__init__":
missing_args = [
a.arg for a in fn.args.args
if a.arg != "self" and a.annotation is None
]
missing_ret = fn.returns is None
missing_doc = ast.get_docstring(fn) is None
print("missing_arg_annotations:", missing_args)
print("missing_return_annotation:", missing_ret)
print("missing_docstring:", missing_doc)
PYRepository: delmic/odemis
Length of output: 227
Add type hints and a docstring to FastEMStreamController.__init__.
The constructor is missing all parameter and return type annotations, plus a docstring. These are required by the repository's coding guidelines for Python files.
Proposed patch
+from typing import Any
...
class FastEMStreamController(StreamController):
- def __init__(self, stream_bar, stream, tab_data_model, show_panel=True, view=None,
- sb_ctrl=None, sp_options=None):
+ def __init__(
+ self,
+ stream_bar: Any,
+ stream: acqstream.SEMStream,
+ tab_data_model: Any,
+ show_panel: bool = True,
+ view: Any = None,
+ sb_ctrl: Any = None,
+ sp_options: int | None = None,
+ ) -> None:
+ """
+ Initialize the FastEM stream controller.
+
+ :param stream_bar: Container for stream panels.
+ :param stream: Stream handled by this controller.
+ :param tab_data_model: Tab data model.
+ :param show_panel: Whether to show the panel immediately.
+ :param view: Linked view for visibility handling.
+ :param sb_ctrl: Parent stream bar controller.
+ :param sp_options: StreamPanel option bitmask.
+ """
super().__init__(
stream_bar=stream_bar, stream=stream, tab_data_model=tab_data_model,
show_panel=show_panel, view=view, sb_ctrl=sb_ctrl, sp_options=sp_options
)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/odemis/gui/cont/stream.py` around lines 1384 - 1389, Add parameter and
return type annotations to FastEMStreamController.__init__: annotate stream_bar,
stream, tab_data_model with their concrete types used elsewhere (e.g.,
StreamBar, Stream, TabDataModel), annotate show_panel as bool, view and sb_ctrl
as Optional[...], and sp_options as Optional[dict] (or Optional[Mapping[str,
Any]]), and set the return type to None. Also add a concise docstring to
__init__ describing the purpose of the constructor and each parameter (including
defaults and optionality) and any side effects (e.g., registering with
stream_bar), matching the project's docstring style.
No description provided.