Repository navigation
Chore/lint and docs - #14
Conversation
- Remove unused imports (ruff F401) - Fix f-strings without placeholders (ruff F541) - Resolve E402 import ordering in grabcut_nodes.py - Fix B108 hardcoded /tmp fallback in nodes.py (use tempfile.gettempdir()) - Delete untracked artifacts: .claude/, node.zip, __pycache__/ - Add .claude/ and *.zip to .gitignore
- Add missing dependencies (ultralytics, pydantic, structlog, opencv-contrib) - Document RemoveBackgroundAndResizeNode - Add Development section with testing, linting, and project structure
📝 WalkthroughWalkthroughThis PR performs repository cleanup and maintenance: removing unused imports across multiple files, adding linting directives, updating README with new dependencies and documentation, reorganizing import handling in one module, and simplifying test output strings. No functional behavior changes. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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.
Code Review
This pull request performs extensive cleanup by removing unused imports across the project, updating the .gitignore, and refining test scripts. It also introduces documentation for the RemoveBackgroundAndResizeNode and replaces hardcoded temporary paths with a more robust solution. Feedback was provided to correct the parameter table in the README documentation and to reorganize imports and sys.path modifications in grabcut_nodes.py to follow PEP 8 standards.
| | Parameter | Type | Range/Options | Default | Description | | ||
| |-----------|------|---------------|---------|-------------| | ||
| | **width** | INT | 64-4096 | 512 | Output width | | ||
| | **height** | INT | 64-4096 | 512 | Output height | | ||
| | **upscale_method** | DROPDOWN | NEAREST, BILINEAR, BICUBIC, LANCZOS | LANCZOS | Interpolation method | |
There was a problem hiding this comment.
The parameter table for RemoveBackgroundAndResizeNode is incorrect and does not match the implementation in RemoveBackgroundAndResizeNode.py. The node actually uses parameters like tolerance, foreground_bias, color_clusters, output_size, and scaling_method instead of width, height, and upscale_method.
| | Parameter | Type | Range/Options | Default | Description | | |
| |-----------|------|---------------|---------|-------------| | |
| | **width** | INT | 64-4096 | 512 | Output width | | |
| | **height** | INT | 64-4096 | 512 | Output height | | |
| | **upscale_method** | DROPDOWN | NEAREST, BILINEAR, BICUBIC, LANCZOS | LANCZOS | Interpolation method | | |
| | Parameter | Type | Range/Options | Default | Description | | |
| |-----------|------|---------------|---------|-------------| | |
| | **tolerance** | INT | 0-255 | 30 | Colour distance threshold | | |
| | **foreground_bias** | FLOAT | 0.0-1.0 | 0.7 | Bias toward keeping pixels as foreground | | |
| | **color_clusters** | INT | 2-20 | 8 | Number of k-means centres for colour segmentation | | |
| | **output_size** | DROPDOWN | ORIGINAL, 512x512, 768x768, 1024x1024, 1280x720, 1920x1080 | ORIGINAL | Resize output to this size | | |
| | **scaling_method** | DROPDOWN | NEAREST, BILINEAR, BICUBIC, LANCZOS | LANCZOS | Interpolation method | |
| from __future__ import annotations | ||
|
|
||
| import time | ||
| from typing import Optional, Tuple |
There was a problem hiding this comment.
Standard library imports and sys.path modifications should be placed at the top of the file to adhere to PEP 8 and ensure they are available for subsequent imports. This also avoids the need for # noqa: E402.
| from typing import Optional, Tuple | |
| import os.path as _path | |
| import sys as _sys | |
| from typing import Optional, Tuple | |
| _parent = _path.dirname(__file__) | |
| if _parent not in _sys.path: | |
| _sys.path.insert(0, _parent) | |
| import os.path as _path # noqa: E402 | ||
| import sys as _sys # noqa: E402 | ||
|
|
||
| _parent = _path.dirname(__file__) | ||
| if _parent not in _sys.path: | ||
| _sys.path.insert(0, _parent) |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
__init__.py (1)
3-6: Thenoqadirective is appropriate, but consider simplifying the pattern.The
# noqa: F401directive correctly documents that thesklearnimport is intentionally unused (it's only for the availability check). However, note that according to the coding guidelines, flake8 should only check E9,F63,F7,F82 error codes—F401 isn't in that list, so this directive may be unnecessary if you're following the configured linting rules.Additionally,
SKLEARN_AVAILABLEis assigned on lines 4 and 6 but never actually used within this file. The variable isn't referenced anywhere after being set and isn't exported in__all__. Sincebackground_remover.pymaintains its ownSKLEARN_AVAILABLEflag (as shown in the context snippets), you could simplify this pattern.♻️ Optional refactor to remove unused variable
# Check for optional dependencies and provide helpful warnings try: - import sklearn # noqa: F401 - SKLEARN_AVAILABLE = True + import sklearn # noqa: F401 # Import to verify availability except ImportError: - SKLEARN_AVAILABLE = False print("\n" + "="*70) print("⚠️ TransparencyBackgroundRemover: scikit-learn not installed!") print("="*70)This removes the unused variable while keeping the availability check and warning functionality intact.
As per coding guidelines: "Run flake8 linting with E9,F63,F7,F82 error codes" - F401 is not in this list, so flake8 configured per guidelines wouldn't flag this unused import.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@__init__.py` around lines 3 - 6, Remove the unused SKLEARN_AVAILABLE variable and the unnecessary "# noqa: F401" by simplifying the import check: attempt to import sklearn inside a try/except and, on ImportError, emit a warning (or noop) so callers still get notified without defining or exporting SKLEARN_AVAILABLE in __init__.py; keep background_remover.py's own SKLEARN_AVAILABLE flag unchanged and do not add SKLEARN_AVAILABLE to __all__ in this file.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@README.md`:
- Line 431: The project-structure code fence in README.md is missing a language
identifier (triggers markdownlint MD040); update the opening fence from ``` to
```text for the block that contains the tree (the "project-structure" code fence
/ the fenced block that starts with " . ├── __init__.py") so the fence reads
```text to satisfy markdownlint and preserve the block content.
---
Nitpick comments:
In `@__init__.py`:
- Around line 3-6: Remove the unused SKLEARN_AVAILABLE variable and the
unnecessary "# noqa: F401" by simplifying the import check: attempt to import
sklearn inside a try/except and, on ImportError, emit a warning (or noop) so
callers still get notified without defining or exporting SKLEARN_AVAILABLE in
__init__.py; keep background_remover.py's own SKLEARN_AVAILABLE flag unchanged
and do not add SKLEARN_AVAILABLE to __all__ in this file.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 987ef979-d24d-4fc8-8585-806e996c2977
📒 Files selected for processing (14)
.gitignoreREADME.mdRemoveBackgroundAndResizeNode.py__init__.pybackground_remover.pygrabcut_nodes.pygrabcut_remover.pynodes.pytest_grabcut.pytest_node_import.pytest_power_of_8_scaling.pytest_power_of_8_standalone.pytests/test_grabcut_nodes.pytests/test_grabcut_processor.py
💤 Files with no reviewable changes (3)
- background_remover.py
- tests/test_grabcut_nodes.py
- tests/test_grabcut_processor.py
|
|
||
| ### Project Structure | ||
|
|
||
| ``` |
There was a problem hiding this comment.
Add a language identifier to the project-structure code fence.
This fence is missing a language tag and will trip markdownlint MD040.
Suggested fix
-```
+```text
.
├── __init__.py # ComfyUI node registration
...
└── examples/ # Example images and workflows</details>
<!-- suggestion_start -->
<details>
<summary>📝 Committable suggestion</summary>
> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
```suggestion
🧰 Tools
🪛 markdownlint-cli2 (0.22.0)
[warning] 431-431: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@README.md` at line 431, The project-structure code fence in README.md is
missing a language identifier (triggers markdownlint MD040); update the opening
fence from ``` to ```text for the block that contains the tree (the
"project-structure" code fence / the fenced block that starts with " . ├──
__init__.py") so the fence reads ```text to satisfy markdownlint and preserve
the block content.
Code Review Roast 🔥Verdict: No New Issues Found | Recommendation: Merge Oh wait, this PR is actually clean. I had my flamethrower warmed up and everything. This is just a boring-but-useful linting and documentation cleanup PR. Summary of Changes
Existing Review Feedback (Already Addressed)The previous reviewers already caught the key issues:
Files Reviewed (14 files)
📊 Overall: Like finding a unicorn in production — I didn't think clean PRs existed anymore, but here we are. This PR does exactly what it says on the tin: lint cleanup and documentation updates. Nothing controversial, nothing dangerous. Just some elbow grease making the codebase nicer. Reviewed by minimax-m2.5-20260211 · 473,605 tokens |
Summary by CodeRabbit
New Features
Documentation