Skip to content

Conversation

@Borda
Copy link
Member

@Borda Borda commented Jan 20, 2026

This pull request introduces type annotations throughout the dataset and transform modules, improving code clarity, maintainability, and static analysis. The changes affect function signatures and class methods in files handling COCO, Object365, Roboflow datasets, and image transformations.

Type Annotation Enhancements

  • Added explicit type annotations to all dataset builder functions and utility methods in rfdetr/datasets/__init__.py, coco.py, and o365.py, specifying argument and return types for improved readability and error checking. [1] [2] [3] [4] [5]
  • Updated all transformation functions and classes in rfdetr/datasets/transforms.py to include precise type annotations for image, target, and transformation parameters, facilitating better IDE support and static analysis. [1] [2] [3] [4] [5] [6]
  • Revised COCO evaluation utilities in rfdetr/datasets/coco_eval.py to annotate method arguments and return types, including evaluator methods and helper functions, enhancing code safety and maintainability. [1] [2] [3] [4] [5] [6] [7] [8] [9]

General Improvements

  • Added necessary imports for typing (e.g., Any, Dict, List, Optional, Tuple, Union) across all affected files to support the new type annotations. [1] [2] [3] [4]
  • Improved documentation and code readability by clarifying function signatures and expected input/output types, which will help new contributors and reduce runtime errors. [1] [2] [3] [4] [5]

These changes collectively make the codebase more robust and easier to work with, especially for static analysis tools and future development.

@Borda Borda requested a review from probicheaux as a code owner January 20, 2026 03:03
Copilot AI review requested due to automatic review settings January 20, 2026 03:03
@codecov
Copy link

codecov bot commented Jan 20, 2026

Codecov Report

❌ Patch coverage is 90.66667% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.57%. Comparing base (76c6f5f) to head (7b651bb).

Files with missing lines Patch % Lines
rfdetr/datasets/transforms.py 90.00% 4 Missing ⚠️
rfdetr/datasets/coco_eval.py 87.50% 2 Missing ⚠️
rfdetr/datasets/__init__.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #552      +/-   ##
===========================================
+ Coverage    16.48%   16.57%   +0.08%     
===========================================
  Files           42       42              
  Lines         5557     5564       +7     
===========================================
+ Hits           916      922       +6     
- Misses        4641     4642       +1     
Flag Coverage Δ
Linux 16.57% <90.66%> (+0.08%) ⬆️
Windows 16.57% <90.66%> (+0.08%) ⬆️
cpu 16.57% <90.66%> (+0.08%) ⬆️
macOS 16.57% <90.66%> (+0.08%) ⬆️
python3.10 16.57% <90.66%> (+0.08%) ⬆️
python3.11 16.57% <90.66%> (+0.08%) ⬆️
python3.12 16.57% <90.66%> (+0.08%) ⬆️
python3.13 16.57% <90.66%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds comprehensive type annotations to all dataset-related modules in the rfdetr codebase, enhancing code clarity, maintainability, and enabling better static analysis. The changes are purely additive, introducing type hints without modifying the underlying logic.

Changes:

  • Added type annotations to function signatures and class methods across dataset modules (coco.py, o365.py, coco_eval.py)
  • Enhanced transform classes in transforms.py with precise type annotations for images, targets, and transformation parameters
  • Imported necessary typing utilities (Any, Dict, List, Optional, Tuple, Union) across all affected modules
  • Added explicit return None statement in get_coco_api_from_dataset for clarity
  • Renamed variable pad to pad_op in RandomExpand class to avoid shadowing the pad function

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
rfdetr/datasets/init.py Added type annotations to get_coco_api_from_dataset and build_dataset functions; added explicit return None statement
rfdetr/datasets/coco.py Added type annotations to all utility functions and class methods, including dataset builders and transform factories
rfdetr/datasets/o365.py Added type annotations to Object365 dataset builder functions
rfdetr/datasets/coco_eval.py Added type annotations to CocoEvaluator class methods and utility functions for evaluation
rfdetr/datasets/transforms.py Added comprehensive type annotations to all transformation functions and classes; renamed pad variable to pad_op to avoid shadowing

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

self.p = p

def __call__(self, img, target):
def __call__(self, img: Any, target: Any) -> Any:
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The return type annotation is incorrect. The method returns a tuple of (img, target) from both branches, so the return type should be Tuple[Any, Any] instead of just Any.

Suggested change
def __call__(self, img: Any, target: Any) -> Any:
def __call__(self, img: Any, target: Any) -> Tuple[Any, Any]:

Copilot uses AI. Check for mistakes.
Comment on lines +49 to +50
self.img_ids: List[int] = []
self.eval_imgs: Dict[str, List[Any]] = {k: [] for k in iou_types}
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

While self.img_ids and self.eval_imgs have explicit type annotations, self.coco_eval (defined on line 45) lacks one. For consistency, consider adding a type annotation such as self.coco_eval: Dict[str, COCOeval] when it's initialized.

Copilot uses AI. Check for mistakes.
import os
import contextlib
import copy
from typing import Any, Dict, List, Optional, Tuple, Union
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

Import of 'Optional' is not used.
Import of 'Union' is not used.

Suggested change
from typing import Any, Dict, List, Optional, Tuple, Union
from typing import Any, Dict, List, Tuple

Copilot uses AI. Check for mistakes.
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.

2 participants