From 21482e9109bc8070b6172bfa02f7be0041237d3e Mon Sep 17 00:00:00 2001 From: Jirka Borovec <6035284+Borda@users.noreply.github.com> Date: Tue, 27 Jan 2026 13:06:36 +0900 Subject: [PATCH] typing/assets: Add type hints to methods and polish docstrings (#2087) --- pyproject.toml | 2 -- supervision/assets/downloader.py | 10 +++++----- supervision/assets/list.py | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 3f244f06..13d25c1b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -205,8 +205,6 @@ module = [ # TODO: fix type errors in the following modules "supervision.annotators.core", "supervision.annotators.utils", - "supervision.assets.downloader", - "supervision.assets.list", "supervision.classification.core", "supervision.dataset.core", "supervision.dataset.formats.coco", diff --git a/supervision/assets/downloader.py b/supervision/assets/downloader.py index 4968b541..1dc44e36 100644 --- a/supervision/assets/downloader.py +++ b/supervision/assets/downloader.py @@ -19,11 +19,11 @@ def is_md5_hash_matching(filename: str, original_md5_hash: str) -> bool: not for cryptographic security purposes. Parameters: - filename (str): The path to the file to be checked as a string. - original_md5_hash (str): The original MD5 hash to compare against. + filename: The path to the file to be checked as a string. + original_md5_hash: The original MD5 hash to compare against. Returns: - bool: True if the hashes match, False otherwise. + True if the hashes match, False otherwise. """ if not os.path.exists(filename): return False @@ -40,11 +40,11 @@ def download_assets(asset_name: VideoAssets | str) -> str: Download a specified asset if it doesn't already exist or is corrupted. Parameters: - asset_name (Union[VideoAssets, str]): The name or type of the asset to be + asset_name: The name or type of the asset to be downloaded. Returns: - str: The filename of the downloaded asset. + The filename of the downloaded asset. Example: ```python diff --git a/supervision/assets/list.py b/supervision/assets/list.py index 01bdadc3..0d6d0ae0 100644 --- a/supervision/assets/list.py +++ b/supervision/assets/list.py @@ -34,7 +34,7 @@ class VideoAssets(Enum): SKIING = "skiing.mp4" @classmethod - def list(cls): + def list(cls) -> list[str]: return list(map(lambda c: c.value, cls))