Skip to content

Add types for crop_image_by_bounding_boxes.py - #2060

Open
RishikeshVepura wants to merge 1 commit into
lightly-ai:masterfrom
RishikeshVepura:codex/typecheck-crop-bounding-boxes
Open

Add types for crop_image_by_bounding_boxes.py#2060
RishikeshVepura wants to merge 1 commit into
lightly-ai:masterfrom
RishikeshVepura:codex/typecheck-crop-bounding-boxes

Conversation

@RishikeshVepura

@RishikeshVepura RishikeshVepura commented Sep 9, 2026

Copy link
Copy Markdown

Summary

  • use modern built-in collection annotations
  • mark class_names as optional to match its None default
  • preserve the fixed-length crop-box tuple type
  • enable mypy checking for crop_image_by_bounding_boxes.py

Part of #1635.

Testing

  • make format
  • make static-checks
  • pytest tests/cli/test_cli_crop.py
  • make all-checks

make all-checks completed with 1,468 passed and 209 skipped. One unrelated
distributed DCL test failed locally:

tests/utils/test_dist__gather__losses.py::TestGatherLayer_Losses::test_loss_dcl

The failure reproduces independently and does not involve the modified code.
All crop CLI tests passed.

Adds modern type annotations to crop_image_by_bounding_boxes.py, including optional class_names and fixed-length crop-box tuples. Enables mypy checks for the file.

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 3e671d18-d8b5-4f79-9941-2c1ad06cac41

📥 Commits

Reviewing files that changed from the base of the PR and between 2e5fafb and 8297750.

📒 Files selected for processing (2)
  • lightly/utils/cropping/crop_image_by_bounding_boxes.py
  • pyproject.toml
💤 Files with no reviewable changes (1)
  • pyproject.toml

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

Changes

Typed cropping module

Layer / File(s) Summary
Cropping annotations and mypy coverage
lightly/utils/cropping/crop_image_by_bounding_boxes.py, pyproject.toml
The cropping function uses built-in generic annotations and an explicit nullable class_names type. Local annotations use the same syntax. Crop coordinates convert directly to integers. Mypy now checks the module.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 82977

This change modernizes cropping type annotations, correctly represents optional class names, and enables type checking without an identified behavior regression. It is ready to merge.

🚥 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 clearly and concisely describes the main change: adding type annotations to crop_image_by_bounding_boxes.py.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files.
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.
✨ 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.

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