-
Notifications
You must be signed in to change notification settings - Fork 595
Add type annotations to all dataset-related modules #552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this 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 Nonestatement inget_coco_api_from_datasetfor clarity - Renamed variable
padtopad_opin RandomExpand class to avoid shadowing thepadfunction
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: |
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
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.
| def __call__(self, img: Any, target: Any) -> Any: | |
| def __call__(self, img: Any, target: Any) -> Tuple[Any, Any]: |
| self.img_ids: List[int] = [] | ||
| self.eval_imgs: Dict[str, List[Any]] = {k: [] for k in iou_types} |
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
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.
| import os | ||
| import contextlib | ||
| import copy | ||
| from typing import Any, Dict, List, Optional, Tuple, Union |
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
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.
| from typing import Any, Dict, List, Optional, Tuple, Union | |
| from typing import Any, Dict, List, Tuple |
5e473cd to
7b651bb
Compare
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
rfdetr/datasets/__init__.py,coco.py, ando365.py, specifying argument and return types for improved readability and error checking. [1] [2] [3] [4] [5]rfdetr/datasets/transforms.pyto include precise type annotations for image, target, and transformation parameters, facilitating better IDE support and static analysis. [1] [2] [3] [4] [5] [6]rfdetr/datasets/coco_eval.pyto 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
Any,Dict,List,Optional,Tuple,Union) across all affected files to support the new type annotations. [1] [2] [3] [4]These changes collectively make the codebase more robust and easier to work with, especially for static analysis tools and future development.