Conversation
Reviewer's GuideThis PR replaces Black with Ruff as the project’s code formatter by removing Black configurations and hooks, adding Ruff settings, and auto-formatting the codebase to comply with Ruff’s style rules. Flow diagram for configuration changes in pyproject.tomlflowchart TD
A["pyproject.toml"] -- Remove Black config --> B["No Black settings"]
A -- Add Ruff config --> C["Ruff settings: line-length, exclude, target-version, fix"]
Flow diagram for pre-commit configuration updateflowchart TD
A[".pre-commit-config.yaml"] -- Remove Black repo and hook --> B["No Black hook"]
A -- Add ruff-format hook to Ruff repo --> C["Ruff-format hook active"]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
WalkthroughThe PR switches Python code formatting from Black to ruff-format by updating pre-commit and pyproject.toml configurations, then applies the resulting formatting changes across the codebase—primarily spacing adjustments in f-strings, removal of blank lines, and quote style normalization. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes The diff is composed almost entirely of repetitive, homogeneous formatting adjustments applied by the ruff-format tool switch. Configuration changes in Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ 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.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `package/tests/test_PartSegCore/test_analysis_batch.py:547-548` </location>
<code_context>
</code_context>
<issue_to_address>
**issue (code-quality):** Avoid loops in tests. ([`no-loop-in-tests`](https://docs.sourcery.ai/Reference/Rules-and-In-Line-Suggestions/Python/Default-Rules/no-loop-in-tests))
<details><summary>Explanation</summary>Avoid complex code, like loops, in test functions.
Google's software engineering guidelines says:
"Clear tests are trivially correct upon inspection"
To reach that avoid complex code in tests:
* loops
* conditionals
Some ways to fix this:
* Use parametrized tests to get rid of the loop.
* Move the complex logic into helpers.
* Move the complex part into pytest fixtures.
> Complexity is most often introduced in the form of logic. Logic is defined via the imperative parts of programming languages such as operators, loops, and conditionals. When a piece of code contains logic, you need to do a bit of mental computation to determine its result instead of just reading it off of the screen. It doesn't take much logic to make a test more difficult to reason about.
Software Engineering at Google / [Don't Put Logic in Tests](https://abseil.io/resources/swe-book/html/ch12.html#donapostrophet_put_logic_in_tests)
</details>
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
tutorials/tutorial_neuron_types/Neuron_types_example.ipynb (1)
408-410: Verify functional equivalence of the loop-to-generator refactor.This marks a behavioral change within a formatting pass. The original loop with explicit
touch = Trueandbreakis replaced with anany()generator expression. While functionally equivalent, this refactor should be flagged separately from pure formatting changes for audit clarity.# Original logic touch = False for axis_cords, max_size in zip(coords, current_component_area.shape): if np.max(axis_cords) == max_size - 1: touch = True break # Refactored logic touch = any( np.max(axis_cords) == max_size - 1 for axis_cords, max_size in zip(coords, current_component_area.shape) )Both are equivalent—the generator expression short-circuits just like the explicit break—but this should ideally be called out as a code improvement separate from a formatting PR.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (17)
.pre-commit-config.yaml(1 hunks)package/PartSeg/_roi_analysis/prepare_plan_widget.py(1 hunks)package/PartSeg/common_gui/algorithms_description.py(1 hunks)package/PartSeg/common_gui/multiple_file_widget.py(1 hunks)package/PartSeg/common_gui/napari_image_view.py(1 hunks)package/PartSeg/plugins/napari_io/save_tiff_layer.py(1 hunks)package/PartSegCore/analysis/batch_processing/batch_backend.py(1 hunks)package/PartSegCore/analysis/measurement_calculation.py(1 hunks)package/PartSegCore/class_generator.py(1 hunks)package/PartSegCore/sphinx/auto_parameters.py(2 hunks)package/PartSegImage/image.py(2 hunks)package/tests/test_PartSeg/test_common_gui.py(0 hunks)package/tests/test_PartSeg/test_sentry.py(0 hunks)package/tests/test_PartSegCore/test_algorithm_describe_base.py(0 hunks)package/tests/test_PartSegCore/test_analysis_batch.py(1 hunks)pyproject.toml(1 hunks)tutorials/tutorial_neuron_types/Neuron_types_example.ipynb(16 hunks)
💤 Files with no reviewable changes (3)
- package/tests/test_PartSeg/test_common_gui.py
- package/tests/test_PartSeg/test_sentry.py
- package/tests/test_PartSegCore/test_algorithm_describe_base.py
🧰 Additional context used
🧬 Code graph analysis (5)
package/PartSeg/_roi_analysis/prepare_plan_widget.py (1)
package/PartSeg/common_backend/except_hook.py (1)
show_warning(83-95)
package/PartSeg/common_gui/algorithms_description.py (2)
package/PartSegCore/algorithm_describe_base.py (1)
_pretty_print(539-570)package/PartSegCore/analysis/calculation_plan.py (1)
_pretty_print(810-829)
package/PartSegCore/analysis/measurement_calculation.py (1)
package/PartSegCore/analysis/measurement_base.py (1)
calculate_property(375-399)
package/PartSegCore/analysis/batch_processing/batch_backend.py (1)
package/PartSegCore/json_hooks.py (1)
PartSegEncoder(9-10)
package/PartSeg/plugins/napari_io/save_tiff_layer.py (1)
package/PartSegImage/image.py (2)
channel_names(431-432)shape(654-656)
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (24)
- GitHub Check: 4DNucleome.PartSeg (Tests_other test windows)
- GitHub Check: 4DNucleome.PartSeg (Tests_other test macos)
- GitHub Check: 4DNucleome.PartSeg (Tests_linux test_linux)
- GitHub Check: 4DNucleome.PartSeg (Builds pyinstaller_linux)
- GitHub Check: 4DNucleome.PartSeg (Builds pyinstaller windows)
- GitHub Check: 4DNucleome.PartSeg (Builds pyinstaller macos_arm)
- GitHub Check: 4DNucleome.PartSeg (Builds pyinstaller macos)
- GitHub Check: 4DNucleome.PartSeg (Builds sdist)
- GitHub Check: ubuntu-24.04 py3.12 --pre
- GitHub Check: windows-2022 py3.12 --pre
- GitHub Check: macos-14 py3.12 --pre
- GitHub Check: repo py3.10
- GitHub Check: repo py3.12
- GitHub Check: repo py3.11
- GitHub Check: Base py3.11 / macos-15-intel py 3.11 latest PyQt5
- GitHub Check: Test PartSeg minimal / ubuntu-24.04 py 3.9 latest PyQt5
- GitHub Check: test_coverage / ubuntu-24.04 py 3.12 latest PyQt5
- GitHub Check: 4DNucleome.PartSeg (GetTestData linux)
- GitHub Check: 4DNucleome.PartSeg (Documentation_check Notebook_check)
- GitHub Check: 4DNucleome.PartSeg (manifest_check manifest_check)
- GitHub Check: 4DNucleome.PartSeg (Documentation_check help)
- GitHub Check: 4DNucleome.PartSeg (formatting_check check_formating)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Sourcery review
🔇 Additional comments (15)
package/PartSegCore/analysis/measurement_calculation.py (1)
1449-1453: Formatting change aligns with ruff-format migration.The method signature has been reformatted from a multi-line definition to a single line, consistent with ruff's formatting conventions. The method's behavior and parameters remain unchanged, and the pylint disable comment is preserved.
tutorials/tutorial_neuron_types/Neuron_types_example.ipynb (1)
1-750: Notebook JSON structure is valid and ready.The notebook JSON has been verified and validates correctly. All formatting is intact with no structural errors that would prevent loading or execution.
package/PartSegCore/sphinx/auto_parameters.py (1)
53-53: LGTM! Formatting-only change.The quote style normalization in nested f-strings aligns with ruff-format rules without affecting behavior.
Also applies to: 62-62
package/tests/test_PartSegCore/test_analysis_batch.py (1)
548-548: LGTM! Formatting-only change.Added spaces around the
+operator in the f-string expression, consistent with ruff-format style.package/PartSeg/common_gui/algorithms_description.py (1)
73-73: LGTM! Formatting-only change.Added spaces around the
+operator in the function call, consistent with ruff-format style.package/PartSegCore/class_generator.py (1)
311-313: LGTM! Formatting-only change.The error message string was reformatted without changing its content or behavior.
package/PartSegCore/analysis/batch_processing/batch_backend.py (1)
870-870: LGTM! Formatting-only changes.Added spaces around the
+operator in f-string expressions for Excel cell positions, consistent with ruff-format style.Also applies to: 877-879, 884-884
package/PartSeg/common_gui/multiple_file_widget.py (1)
267-267: LGTM! Formatting-only change.Added spaces around the
+operator in the f-string expression, consistent with ruff-format style.package/PartSeg/_roi_analysis/prepare_plan_widget.py (1)
870-870: LGTM! Formatting-only change.Quote style normalization in the f-string aligns with ruff-format rules without affecting behavior.
package/PartSeg/common_gui/napari_image_view.py (1)
1053-1053: LGTM! Formatting-only change.Quote style normalization in the nested f-string aligns with ruff-format rules without affecting behavior.
package/PartSeg/plugins/napari_io/save_tiff_layer.py (1)
45-45: LGTM! Formatting changes are consistent with Ruff style.These formatting adjustments (quote style in f-strings and spacing in slice notation) have no semantic impact and align with Ruff's formatting conventions.
Also applies to: 49-49
package/PartSegImage/image.py (1)
287-287: LGTM! Consistent spacing in f-strings.The spacing around the
+operator improves readability and follows PEP 8 conventions. No functional changes to channel naming behavior.Also applies to: 301-301
pyproject.toml (1)
266-280: LGTM! Comprehensive Ruff exclusion list.The expanded exclude list appropriately covers version control directories, build artifacts, virtual environments, and generated files. This configuration properly replaces the removed Black configuration.
.pre-commit-config.yaml (2)
18-18: LGTM! Ruff formatter integration complete.Adding the
ruff-formathook alongsideruff-checkproperly completes the migration from Black to Ruff for automated formatting checks.
30-35: LGTM! Enhanced markdown formatting capabilities.The additional mdformat dependencies (GFM, frontmatter, footnotes, alerts, ruff integration, and TOC support) provide comprehensive markdown formatting coverage aligned with the broader Ruff migration.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1324 +/- ##
===========================================
- Coverage 93.20% 93.18% -0.02%
===========================================
Files 210 210
Lines 33365 33365
===========================================
- Hits 31097 31092 -5
- Misses 2268 2273 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|



Summary by Sourcery
Replace Black with Ruff as the project’s code formatter and reformat the entire codebase accordingly
Enhancements:
CI:
Summary by CodeRabbit