diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 98d8d364..85b49dfb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -53,3 +53,11 @@ repos: - id: codespell additional_dependencies: - tomli + + - repo: https://github.com/asottile/pyupgrade + rev: v3.20.0 + hooks: + - id: pyupgrade + args: ["--py39-plus"] + additional_dependencies: + - tomli diff --git a/supervision/detection/vlm.py b/supervision/detection/vlm.py index c07f4170..d98405e3 100644 --- a/supervision/detection/vlm.py +++ b/supervision/detection/vlm.py @@ -118,7 +118,7 @@ def from_paligemma( Args: result: String containing paligemma-formatted locations and labels. - resolution_wh: Tuple (width, height) to which we scale the box coordinates. + resolution_wh: tuple (width, height) to which we scale the box coordinates. classes: Optional list of valid class names. If provided, boxes and labels not in this list are filtered out. @@ -423,9 +423,9 @@ def from_google_gemini_2_0( def from_google_gemini_2_5( result: str, - resolution_wh: Tuple[int, int], - classes: Optional[List[str]] = None, -) -> Tuple[ + resolution_wh: tuple[int, int], + classes: Optional[list[str]] = None, +) -> tuple[ np.ndarray, Optional[np.ndarray], np.ndarray, diff --git a/supervision/validators/__init__.py b/supervision/validators/__init__.py index 5a2ffc98..97fedabd 100644 --- a/supervision/validators/__init__.py +++ b/supervision/validators/__init__.py @@ -1,4 +1,5 @@ from typing import Any + import numpy as np @@ -139,7 +140,7 @@ def validate_keypoints_fields( validate_data(data, n) -def validate_resolution(resolution: Any) -> Tuple[int, int]: +def validate_resolution(resolution: Any) -> tuple[int, int]: if not (isinstance(resolution, tuple) and len(resolution) == 2): raise ValueError( f""" diff --git a/test/detection/test_vlm.py b/test/detection/test_vlm.py index 54a7cf47..93e030a6 100644 --- a/test/detection/test_vlm.py +++ b/test/detection/test_vlm.py @@ -1080,10 +1080,10 @@ def test_florence_2( def test_from_google_gemini_2_5( exception, result: str, - resolution_wh: Tuple[int, int], - classes: Optional[List[str]], + resolution_wh: tuple[int, int], + classes: Optional[list[str]], expected_results: Optional[ - Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray] + tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray] ], ): with exception: