Skip to content

Refactor/typing tracker#2131

Open
danielsamo-se wants to merge 11 commits intoroboflow:developfrom
danielsamo-se:refactor/typing-tracker
Open

Refactor/typing tracker#2131
danielsamo-se wants to merge 11 commits intoroboflow:developfrom
danielsamo-se:refactor/typing-tracker

Conversation

@danielsamo-se
Copy link
Contributor

Before submitting
  • Self-reviewed the code
  • Updated documentation, follow Google-style
  • All tests pass locally

Description

Refactored the byte_tracker module to improve type safety and standardize docstrings.

Type of Change

  • Refactoring (no functional changes)

Motivation and Context

The code was using mixed documentation styles. I updated it to match the project standard and added missing type hints for better IDE support.

Changes Made

  • core.py: added type hints and fixed docstrings
  • single_object_track.py: refactored the track class and improved numpy typing
  • kalman_filter.py, matching.py, utils.py: general cleanup

Testing

  • I have tested this code locally
  • All new and existing tests pass

@codecov
Copy link

codecov bot commented Feb 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72%. Comparing base (ea3a0e9) to head (be02f2c).

Additional details and impacted files
@@           Coverage Diff           @@
##           develop   #2131   +/-   ##
=======================================
  Coverage       72%     72%           
=======================================
  Files           61      61           
  Lines         7245    7250    +5     
=======================================
+ Hits          5242    5247    +5     
  Misses        2003    2003           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@danielsamo-se
Copy link
Contributor Author

The link checker failed with a 503 error on docs/changelog.md, which I didn't modify. Since I don't have permission to re run the job, could a maintainer please trigger it for me?

@Borda Borda requested review from Copilot February 4, 2026 11:31
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 PR refactors the byte_tracker module to improve type safety by adding comprehensive type hints using numpy.typing and standardizing all docstrings to follow the project's Google-style documentation format. Additionally, a typo in the documentation was fixed (correcting "augmentation" to "albumentations").

Changes:

  • Added proper numpy type hints (npt.NDArray[np.float32]) throughout the byte_tracker module
  • Converted all docstrings from mixed styles to Google-style format
  • Fixed return type annotation for sub_tracks function (was list[int], now correctly list[STrack])
  • Fixed typo in documentation: "augmentation" → "albumentations"

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
src/supervision/tracker/byte_tracker/utils.py Added Google-style docstrings for IdCounter class methods with proper type hints
src/supervision/tracker/byte_tracker/single_object_track.py Updated update() method docstring to Google-style and added type hints to static methods (tlwh_to_xyah, tlbr_to_tlwh, tlwh_to_tlbr)
src/supervision/tracker/byte_tracker/matching.py Added numpy.typing import and comprehensive type hints for all function signatures including npt.NDArray[np.float32]
src/supervision/tracker/byte_tracker/kalman_filter.py Reformatted all docstrings to Google-style, added type hints with npt.NDArray[np.float32] for all methods, and improved documentation clarity
src/supervision/tracker/byte_tracker/core.py Standardized parameter documentation style (removing type annotations in docstrings), fixed return type for sub_tracks function from incorrect list[int] to correct list[STrack]
docs/how_to/process_datasets.md Fixed typo in pip install command: "augmentation" → "albumentations"

start_id: The starting integer for the counter.

Raises:
ValueError: If start_id is less than or equal to NO_ID.
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

The docstring references "NO_ID" but this is actually a property (self.NO_ID), not a constant. The error message should be clearer about what NO_ID is, or the documentation should specify it's a property that returns -1. Consider updating to: "ValueError: If start_id is less than or equal to -1."

Suggested change
ValueError: If start_id is less than or equal to NO_ID.
ValueError: If start_id is less than or equal to -1.

Copilot uses AI. Check for mistakes.

def iou_distance(atracks: list[STrack], btracks: list[STrack]) -> np.ndarray:
def iou_distance(
atracks: list[STrack] | list[npt.NDArray], btracks: list[STrack] | list[npt.NDArray]
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

The type hint "list[npt.NDArray]" is ambiguous and should specify the numpy array dtype for consistency with the rest of the codebase. Consider using "list[STrack] | list[npt.NDArray[np.float32]]" to be more specific about the array type expected.

Suggested change
atracks: list[STrack] | list[npt.NDArray], btracks: list[STrack] | list[npt.NDArray]
atracks: list[STrack] | list[npt.NDArray[np.float32]],
btracks: list[STrack] | list[npt.NDArray[np.float32]],

Copilot uses AI. Check for mistakes.
@Borda Borda added enhancement New feature or request python Pull requests that update Python code labels Feb 4, 2026
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request python Pull requests that update Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants