Skip to content

[fix] minor fixes#3486

Open
pieleric wants to merge 3 commits into
delmic:masterfrom
pieleric:fix-minor-fixes
Open

[fix] minor fixes#3486
pieleric wants to merge 3 commits into
delmic:masterfrom
pieleric:fix-minor-fixes

Conversation

@pieleric

@pieleric pieleric commented Jun 11, 2026

Copy link
Copy Markdown
Member

Small fixes to issues found automatically, via Github CodeQL, or via grep " (dict|tuple|list|set)\[" -IER .

Slider.__del__() does some important cleanups, which need to also be
done by NumberSlider.

Found by Github CodeQL.
Copilot AI review requested due to automatic review settings June 11, 2026 07:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR applies a small set of “minor fixes” across GUI and acquisition modules, primarily tightening type annotations and improving cleanup behavior.

Changes:

  • Adjusts typing usage in the multipoint correlation controller (stream_groups / previous_group annotations).
  • Ensures NumberSlider teardown also invokes base slider cleanup.
  • Adds a type hint + docstring tweak to the tiled acquisition DA-sorting helper.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/odemis/gui/cont/multi_point_correlation.py Updates typing imports and annotations for stream grouping state.
src/odemis/gui/comp/slider.py Updates NumberSlider.__del__ to call superclass destructor.
src/odemis/acq/stitching/_tiledacq.py Adds type hint to leader_quality and simplifies branching logic.
src/odemis/acq/align/goffset.py Switches a local variable annotation to use Dict[...].

Comment on lines 222 to +225
self.stream_groups: Optional[
dict[tuple[tuple[int], tuple[float]], list[int]]] = None # Dictionary to hold the stream groups
Dict[Tuple[Tuple[int], Tuple[float]], List[int]]] = None # Dictionary to hold the stream groups
# Key of the selected group chosen previously
self.previous_group: Optional[tuple[tuple[int], tuple[float]]] = None
self.previous_group: Optional[Tuple[Tuple[int], Tuple[float]]] = None
Comment thread src/odemis/gui/comp/slider.py
Comment thread src/odemis/acq/stitching/_tiledacq.py
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@pieleric, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 22 minutes and 9 seconds. Learn how PR review limits work.

Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ca6bd367-e85b-4eb9-af04-4c5d826044ca

📥 Commits

Reviewing files that changed from the base of the PR and between 92d736e and 405bfb8.

📒 Files selected for processing (4)
  • plugins/sparc2_alignment_data_collector.py
  • src/odemis/acq/align/goffset.py
  • src/odemis/acq/stitching/_tiledacq.py
  • src/odemis/gui/cont/multi_point_correlation.py
📝 Walkthrough

Walkthrough

This PR improves type safety and cleanup robustness across the acquisition and GUI modules. It adds explicit type annotations to a results dictionary and function parameter in alignment and stitching code, ensures proper destructor chaining in NumberSlider to invoke base class cleanup, and standardizes type annotations in the multi-point correlation GUI component to use typing module generics instead of built-in forms.

Possibly related PRs

  • delmic/odemis#3395: Adds alignment auto-detection logic to goffset.py; this PR complements it by adding explicit type annotations to the results mapping used in that function.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title '[fix] minor fixes' is too vague and generic, using non-descriptive terms that don't convey meaningful information about the specific changes made in the changeset. Consider using a more specific title that describes the actual changes, such as 'Add type annotations and fix destructor calls' or mention the primary change across the modified files.
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess whether the description relates to the changeset. Add a pull request description that explains the purpose and scope of these minor fixes, such as why type annotations were added and why the destructor call was needed.
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
src/odemis/gui/cont/multi_point_correlation.py (1)

31-31: 💤 Low value

Consider using built-in generic types for Python 3.10+ compatibility.

Since the coding guidelines specify Python 3.10+, you can use lowercase built-in generics (dict, list, tuple) directly instead of importing from typing, following PEP 585. While the current change brings consistency with existing List and Optional imports, the modern approach would be:

self.stream_groups: dict[tuple[tuple[int], tuple[float]], list[int]] | None = None
self.previous_group: tuple[tuple[int], tuple[float]] | None = None

This would also allow removing Dict from the typing imports and eventually migrating other annotations (Listlist, Optional[X]X | None).

Also applies to: 223-225

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/odemis/gui/cont/multi_point_correlation.py` at line 31, Update
annotations to use PEP 585/604 built-in generics and native union syntax: remove
or stop using Dict/List/Optional/Union from typing and change the annotations
for self.stream_groups and self.previous_group (and the similar annotations at
lines ~223-225) to use dict, list and X | None and tuple[...] forms (e.g.,
dict[tuple[tuple[int], tuple[float]], list[int]] | None and tuple[tuple[int],
tuple[float]] | None) and adjust the import line (from typing import Tuple)
accordingly so typing imports no longer include Dict/List/Optional/Union.

Source: Coding guidelines

src/odemis/acq/align/goffset.py (1)

609-609: ⚡ Quick win

Use Tuple from typing for consistency and specify element types.

The annotation mixes Dict from the typing module with the built-in tuple. For consistency, use Tuple from typing (already imported on line 16). Additionally, specify the tuple element types for better type safety—based on the test evidence, keys are (grating_index, detector_name) pairs.

🔧 Suggested fix
-    results: Dict[tuple, bool] = {}
+    results: Dict[Tuple[int, str], bool] = {}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/odemis/acq/align/goffset.py` at line 609, Replace the loose annotation
"results: Dict[tuple, bool] = {}" with a typed tuple using the typing.Tuple
already imported; update it to "results: Dict[Tuple[int, str], bool] = {}" (keys
are (grating_index: int, detector_name: str)) so the dict uses consistent typing
and explicit element types.

Source: Coding guidelines

src/odemis/acq/stitching/_tiledacq.py (1)

556-558: ⚡ Quick win

Remove type information from the docstring.

The docstring includes :return float:, but the coding guidelines require docstrings "without type information". The return type is already declared in the function signature (-> float), so the docstring should not duplicate it.

📝 Suggested fix
         def leader_quality(da: model.DataArray) -> float:
             """
-            :return float: (> 0) The bigger, the more leadership
+            :return: (> 0) The bigger, the more leadership
             """
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/odemis/acq/stitching/_tiledacq.py` around lines 556 - 558, The docstring
for leader_quality(da: model.DataArray) duplicates the return type; remove the
type information so it only describes the return value (e.g., "Return the
leadership score; the bigger, the more leadership") and leave the function
signature's -> float to convey the type; update the triple-quoted string inside
leader_quality accordingly so no ":return float:" or other type annotations
remain.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/odemis/gui/comp/slider.py`:
- Around line 575-578: The destructor __del__ is missing a return type
annotation and a docstring; update the method signature to include -> None and
add a concise docstring describing that it unbinds the linked_field
EVT_COMMAND_ENTER handler (self._update_slider) during cleanup and then calls
the superclass destructor; reference the symbols __del__, linked_field, Unbind,
_update_slider and super().__del__ to locate where to add the annotation and
docstring.

---

Nitpick comments:
In `@src/odemis/acq/align/goffset.py`:
- Line 609: Replace the loose annotation "results: Dict[tuple, bool] = {}" with
a typed tuple using the typing.Tuple already imported; update it to "results:
Dict[Tuple[int, str], bool] = {}" (keys are (grating_index: int, detector_name:
str)) so the dict uses consistent typing and explicit element types.

In `@src/odemis/acq/stitching/_tiledacq.py`:
- Around line 556-558: The docstring for leader_quality(da: model.DataArray)
duplicates the return type; remove the type information so it only describes the
return value (e.g., "Return the leadership score; the bigger, the more
leadership") and leave the function signature's -> float to convey the type;
update the triple-quoted string inside leader_quality accordingly so no ":return
float:" or other type annotations remain.

In `@src/odemis/gui/cont/multi_point_correlation.py`:
- Line 31: Update annotations to use PEP 585/604 built-in generics and native
union syntax: remove or stop using Dict/List/Optional/Union from typing and
change the annotations for self.stream_groups and self.previous_group (and the
similar annotations at lines ~223-225) to use dict, list and X | None and
tuple[...] forms (e.g., dict[tuple[tuple[int], tuple[float]], list[int]] | None
and tuple[tuple[int], tuple[float]] | None) and adjust the import line (from
typing import Tuple) accordingly so typing imports no longer include
Dict/List/Optional/Union.
🪄 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: 16a71d28-3cd1-46a7-9b6a-2ac679214e92

📥 Commits

Reviewing files that changed from the base of the PR and between f74a181 and 92d736e.

📒 Files selected for processing (4)
  • src/odemis/acq/align/goffset.py
  • src/odemis/acq/stitching/_tiledacq.py
  • src/odemis/gui/comp/slider.py
  • src/odemis/gui/cont/multi_point_correlation.py

Comment thread src/odemis/gui/comp/slider.py
pieleric added 2 commits June 11, 2026 09:10
It should always return a positive float, but could return None if the
metadata is missing.

Found by Github CodeQL.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants