mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-06 21:43:59 +08:00
Mark stub-only private symbols as @type_check_only in third-party stubs (#14545)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user