add missing and modern typehints#302
Merged
Merged
Conversation
Removed unused import statement for 'Any'.
Collaborator
|
Hi @omkar-334, can you make the necessary changes so the pre-commit check passes? |
Contributor
Author
hey @SkalskiP the pre-commit check is passing now. thanks! |
Contributor
Author
|
hey @SkalskiP , can you review this? |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to modernize and fill in missing type hints across the CLI/script layer, I/O utilities, evaluation package exports, and a small ByteTrack component, with minor test assertions to strengthen typing expectations.
Changes:
- Add/modernize type annotations in
track.py, MOT/video I/O context managers, and ByteTrack Kalman state initialization. - Adjust
trackers.evalpackage exports (including adding direct imports of evaluate helpers). - Add a few assertions in integration tests to make expected types/metric presence explicit.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
trackers/scripts/track.py |
Adds TYPE_CHECKING import and types for model/tracker helpers. |
trackers/io/video.py |
Adds explicit return types for context manager methods. |
trackers/io/mot.py |
Adds TextIO typing for file handle and context manager return types. |
trackers/eval/__init__.py |
Exports evaluate helpers and adjusts __getattr__ typing (but introduces a circular import risk). |
trackers/core/bytetrack/kalman.py |
Adds -> None to __init__. |
test/core/test_tracker_integration.py |
Adds assertions to clarify expected runtime types/metric presence. |
- Remove eager `from trackers.eval.evaluate import ...` added in typeh branch - Keep existing `__getattr__` lazy-load handler (it was never dead code) trackers/io/mot.py imports trackers.eval.box, which executes trackers/eval/__init__.py. The eager import then ran trackers/eval/evaluate, which imports back from trackers.io.mot while it is still partially initialized, causing an ImportError on any import order where mot is loaded first. CI passed because the test suite happened to initialize trackers.eval first. [resolve roboflow#2] Review comment by Copilot (PR roboflow#302): "Importing evaluate_mot_sequence/evaluate_mot_sequences at module import time creates a circular import..." --- Co-authored-by: Claude Code <noreply@anthropic.com>
_DisplayWindow.__exit__ and _MOTOutput.__exit__ used bare `*_` while _VideoOutput.__exit__ used `*_: object`. All three context managers should be consistent since the PR purpose is adding type hints. [resolve roboflow#3] /review finding by foundry:sw-engineer (report: .temp/output-review-typeh-2026-04-23.md): "Inconsistent __exit__ parameter annotations..." --- Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Added `from __future__ import annotations` for type hint evaluation. - Leveraged `TYPE_CHECKING` to conditionally import evaluation functions. - Preserved lazy-loading via `__getattr__` to avoid circular import issues.
Borda
approved these changes
Apr 23, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR adds missing typehints, and modernizes existing typehints wherever applicable
Type of Change