Mark stub-only private symbols as @type_check_only in third-party stubs (#14545)

This commit is contained in:
Brian Schubert
2025-08-08 05:29:48 -04:00
committed by GitHub
parent a358dc24e8
commit 81c8fcb2e6
131 changed files with 334 additions and 147 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
from typing import TypedDict
from typing import TypedDict, type_check_only
# Unused in this module, but imported in multiple submodules.
@type_check_only
class _EncodedRLE(TypedDict): # noqa: Y049
size: list[int]
counts: str | bytes
+7 -1
View File
@@ -1,6 +1,6 @@
from collections.abc import Collection, Sequence
from pathlib import Path
from typing import Generic, Literal, TypedDict, TypeVar, overload
from typing import Generic, Literal, TypedDict, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias
import numpy as np
@@ -10,6 +10,7 @@ from . import _EncodedRLE
PYTHON_VERSION: int
@type_check_only
class _Image(TypedDict):
id: int
width: int
@@ -18,10 +19,12 @@ class _Image(TypedDict):
_TPolygonSegmentation: TypeAlias = list[list[float]]
@type_check_only
class _RLE(TypedDict):
size: list[int]
counts: list[int]
@type_check_only
class _Annotation(TypedDict):
id: int
image_id: int
@@ -33,6 +36,7 @@ class _Annotation(TypedDict):
_TSeg = TypeVar("_TSeg", _TPolygonSegmentation, _RLE, _EncodedRLE)
@type_check_only
class _AnnotationG(TypedDict, Generic[_TSeg]):
id: int
image_id: int
@@ -42,11 +46,13 @@ class _AnnotationG(TypedDict, Generic[_TSeg]):
bbox: list[float]
iscrowd: int
@type_check_only
class _Category(TypedDict):
id: int
name: str
supercategory: str
@type_check_only
class _Dataset(TypedDict):
images: list[_Image]
annotations: list[_Annotation]
+3 -1
View File
@@ -1,4 +1,4 @@
from typing import Literal, TypedDict
from typing import Literal, TypedDict, type_check_only
from typing_extensions import TypeAlias
import numpy as np
@@ -9,6 +9,7 @@ from .coco import COCO
_NDFloatArray: TypeAlias = npt.NDArray[np.float64]
_TIOU: TypeAlias = Literal["segm", "bbox", "keypoints"]
@type_check_only
class _ImageEvaluationResult(TypedDict):
image_id: int
category_id: int
@@ -22,6 +23,7 @@ class _ImageEvaluationResult(TypedDict):
gtIgnore: _NDFloatArray
dtIgnore: _NDFloatArray
@type_check_only
class _EvaluationResult(TypedDict):
params: Params
counts: list[int]