Skip to content

add missing and modern typehints#302

Merged
Borda merged 15 commits into
roboflow:developfrom
omkar-334:typeh
Apr 23, 2026
Merged

add missing and modern typehints#302
Borda merged 15 commits into
roboflow:developfrom
omkar-334:typeh

Conversation

@omkar-334
Copy link
Copy Markdown
Contributor

What does this PR do?

This PR adds missing typehints, and modernizes existing typehints wherever applicable

Type of Change

  • Documentation update

@omkar-334 omkar-334 requested a review from SkalskiP as a code owner February 28, 2026 19:25
@SkalskiP
Copy link
Copy Markdown
Collaborator

SkalskiP commented Mar 9, 2026

Hi @omkar-334, can you make the necessary changes so the pre-commit check passes?

@omkar-334
Copy link
Copy Markdown
Contributor Author

Hi @omkar-334, can you make the necessary changes so the pre-commit check passes?

hey @SkalskiP the pre-commit check is passing now. thanks!

@omkar-334
Copy link
Copy Markdown
Contributor Author

hey @SkalskiP , can you review this?

Copy link
Copy Markdown
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 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.eval package 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.

Comment thread trackers/eval/__init__.py Outdated
Comment thread trackers/scripts/track.py
Borda and others added 7 commits April 23, 2026 21:14
- 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 Borda merged commit 2cb88b4 into roboflow:develop Apr 23, 2026
17 checks passed
@Borda Borda mentioned this pull request May 6, 2026
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.

4 participants