Skip to content

Conversation

@Czaki
Copy link
Collaborator

@Czaki Czaki commented Feb 3, 2026

Summary by Sourcery

Bug Fixes:

  • Prevent errors during NapariQtViewer initialization when the underlying widget has no layout in newer napari versions.

Summary by CodeRabbit

  • Bug Fixes

    • Resolved a stability issue in the image viewer that could cause errors when the interface layout is unavailable.
  • Chores

    • Updated internal reference data and configurations.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Feb 3, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts NapariQtViewer initialization to be compatible with napari 0.7.0 by safely accessing the main widget layout before modifying margins.

Class diagram for updated NapariQtViewer initialization

classDiagram
    class QtViewer

    class NapariQtViewer {
        +NapariQtViewer(viewer)
        +dragEnterEvent(event)
    }

    NapariQtViewer --|> QtViewer
Loading

File-Level Changes

Change Details Files
Make QtViewer layout margin adjustment conditional on layout existence for forward compatibility with napari 0.7.0.
  • Store the result of self.widget(0).layout() in a local variable before use.
  • Add a None-check guard around the layout object before setting contents margins.
  • Document with a comment that the margin adjustment applies to napari versions before 0.7.0.
package/PartSeg/common_gui/napari_image_view.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@Czaki Czaki added this to the 0.16.5 milestone Feb 3, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 3, 2026

📝 Walkthrough

Walkthrough

This PR updates a project dictionary entry version and adds a new QtViewer entry, while also adding a defensive null-check guard around layout margin adjustments in the NapariQtViewer initialization to prevent failures when layout is unavailable.

Changes

Cohort / File(s) Summary
Project Configuration
.github/project_dict.pws
Updated personal_ws-1.1 en version from 22 to 29; added new QtViewer entry under ImageJ section.
Napari Viewer Layout Safety
package/PartSeg/common_gui/napari_image_view.py
Added null-check guard before calling setContentsMargins on layout in NapariQtViewer initialization to handle cases where layout might be None (pre-napari 0.7.0 compatibility).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A version bump and a safety guard,
QtViewer joins the fold,
Layout checks make code less hard,
Napari's story unfolds,
Small changes, robustly bold! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: fixing QtViewer initialization to prepare for napari 0.7.0 compatibility, which aligns with the core change in napari_image_view.py.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix_start_napari

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.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Consider making the version-dependent behavior explicit (e.g., via a helper or version check) instead of relying on layout is not None plus a comment, so future maintainers understand in which napari versions this branch is expected to run.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider making the version-dependent behavior explicit (e.g., via a helper or version check) instead of relying on `layout is not None` plus a comment, so future maintainers understand in which napari versions this branch is expected to run.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 3, 2026

@codecov
Copy link

codecov bot commented Feb 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.15%. Comparing base (4510409) to head (5915dab).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1351      +/-   ##
===========================================
- Coverage    93.17%   93.15%   -0.02%     
===========================================
  Files          210      210              
  Lines        33251    33253       +2     
===========================================
- Hits         30981    30978       -3     
- Misses        2270     2275       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Czaki Czaki merged commit 55dfe6d into develop Feb 4, 2026
58 checks passed
@Czaki Czaki deleted the fix_start_napari branch February 4, 2026 08:04
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