Skip to content

Chore/lint and docs - #14

Merged
Limbicnation merged 2 commits into
mainfrom
chore/lint-and-docs
Apr 22, 2026
Merged

Limbicnation merged 2 commits into
mainfrom
chore/lint-and-docs

Conversation

@Limbicnation

@Limbicnation Limbicnation commented Apr 22, 2026 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added a standalone background removal node with integrated resize capability, including parameters for width, height, and upscale method.
    • Expanded dependency support for enhanced image processing (YOLO, Pydantic, Structlog).
  • Documentation

    • Updated README with comprehensive dependency list and new node documentation.
    • Added development section with testing, linting, and security scanning guidelines.

- 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
@coderabbitai

coderabbitai Bot commented Apr 22, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This 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

Cohort / File(s) Summary
Configuration & Documentation
.gitignore, README.md
Added IDE/archive ignores (.claude/, *.zip); expanded dependency list to include opencv-contrib-python, ultralytics, pydantic, structlog; introduced new "Remove Background and Resize Node" section and "Development" section with testing/linting/security commands and project structure.
Import Optimization
RemoveBackgroundAndResizeNode.py, grabcut_remover.py, background_remover.py, nodes.py
Removed unused type imports (Optional, List, Tuple) and module imports (colorsys, os); updated mock temp directory to use tempfile.gettempdir().
Linting & Path Handling
__init__.py, grabcut_nodes.py
Added # noqa: F401 annotations to intentionally unused imports; consolidated path-insertion logic in grabcut_nodes.py to execute once at module top, removed time import, eliminated duplicate path-setup block.
Test Cleanup
test_grabcut.py, test_node_import.py, test_power_of_8_scaling.py, test_power_of_8_standalone.py, tests/test_grabcut_nodes.py, tests/test_grabcut_processor.py
Removed unused imports (Path, time, pytest, cv2 in specific tests); simplified static string outputs by replacing unnecessary f-strings with plain strings.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Poem

🐰 Import lines trimmed with careful hands,
Linting directives help the code stand.
A README grows with knowledge anew,
Tests simplified, paths made true—
Clean code hops forward, fresh as the spring! 🌿✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Chore/lint and docs' accurately reflects the pull request's primary changes: removing unused imports, cleaning up linting issues, and updating documentation.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% 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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/lint-and-docs

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread README.md
Comment on lines +390 to +394
| 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 |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
| 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 |

Comment thread grabcut_nodes.py
from __future__ import annotations

import time
from typing import Optional, Tuple

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
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)

Comment thread grabcut_nodes.py
Comment on lines +12 to +17
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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

These lines should be removed as they have been moved to the top of the file to comply with PEP 8.

@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 (1)
__init__.py (1)

3-6: The noqa directive is appropriate, but consider simplifying the pattern.

The # noqa: F401 directive correctly documents that the sklearn import 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_AVAILABLE is 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__. Since background_remover.py maintains its own SKLEARN_AVAILABLE flag (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

📥 Commits

Reviewing files that changed from the base of the PR and between 5e88049 and d53c734.

📒 Files selected for processing (14)
  • .gitignore
  • README.md
  • RemoveBackgroundAndResizeNode.py
  • __init__.py
  • background_remover.py
  • grabcut_nodes.py
  • grabcut_remover.py
  • nodes.py
  • test_grabcut.py
  • test_node_import.py
  • test_power_of_8_scaling.py
  • test_power_of_8_standalone.py
  • tests/test_grabcut_nodes.py
  • tests/test_grabcut_processor.py
💤 Files with no reviewable changes (3)
  • background_remover.py
  • tests/test_grabcut_nodes.py
  • tests/test_grabcut_processor.py

Comment thread README.md

### Project Structure

```

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

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.

@kilo-code-bot

kilo-code-bot Bot commented Apr 22, 2026 •

Copy link
Copy Markdown

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

Category Details
Import cleanup Removed unused time, colorsys, os, Optional, pytest, cv2 imports
Linting Added # noqa: F401 comments where needed
Bug fixes Fixed unnecessary f-strings (f"..." → "...")
Portability Changed hardcoded /tmp → tempfile.gettempdir()
Docs Added documentation for RemoveBackgroundAndResizeNode
.gitignore Added .claude/ and *.zip entries

Existing Review Feedback (Already Addressed)

The previous reviewers already caught the key issues:

Issue Reviewer Status
README parameter table mismatch gemini-code-assist ✅ Already flagged
Import ordering in grabcut_nodes.py gemini-code-assit ⚠️ Style preference
Unused SKLEARN_AVAILABLE in init.py coderabbit ⚠️ Minor issue

Files Reviewed (14 files)

  • .gitignore
  • README.md
  • RemoveBackgroundAndResizeNode.py
  • __init__.py
  • background_remover.py
  • grabcut_nodes.py
  • grabcut_remover.py
  • nodes.py
  • test_grabcut.py
  • test_node_import.py
  • test_power_of_8_scaling.py
  • test_power_of_8_standalone.py
  • tests/test_grabcut_nodes.py
  • tests/test_grabcut_processor.py

📊 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

@Limbicnation
Limbicnation merged commit 74bb29d into main Apr 22, 2026
5 checks passed
@Limbicnation
Limbicnation deleted the chore/lint-and-docs branch April 22, 2026 03:53
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