From ae9e2d263942aea92e479c9406d5a788465ba3a1 Mon Sep 17 00:00:00 2001 From: Hoel Bagard Date: Fri, 4 Nov 2022 11:32:37 +0900 Subject: [PATCH 01/32] Added the coco.pyi file. --- pyrightconfig.stricter.json | 1 + stubs/pycocotools/pycocotools/__init__.pyi | 0 stubs/pycocotools/pycocotools/coco.pyi | 40 +++++++++++ stubs/pycocotools/pycocotools/coco_types.pyi | 72 ++++++++++++++++++++ 4 files changed, 113 insertions(+) create mode 100644 stubs/pycocotools/pycocotools/__init__.pyi create mode 100644 stubs/pycocotools/pycocotools/coco.pyi create mode 100644 stubs/pycocotools/pycocotools/coco_types.pyi diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index ca21a886d7b1..3c21dea34e4a 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -59,6 +59,7 @@ "stubs/peewee", "stubs/psutil", "stubs/psycopg2", + "stubs/pycocotools", "stubs/pyflakes", "stubs/Pygments", "stubs/PyMySQL", diff --git a/stubs/pycocotools/pycocotools/__init__.pyi b/stubs/pycocotools/pycocotools/__init__.pyi new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/stubs/pycocotools/pycocotools/coco.pyi b/stubs/pycocotools/pycocotools/coco.pyi new file mode 100644 index 000000000000..c7e6c8d3ad9f --- /dev/null +++ b/stubs/pycocotools/pycocotools/coco.pyi @@ -0,0 +1,40 @@ +from pathlib import Path +from typing import Literal, overload + +import numpy as np +import numpy.typing as npt +from _typeshed import Incomplete +from typing_extensions import Self + +from .coco_types import _Annotation, _AnnotationG, _Category, _Dataset, _EncodedRLE, _Image, _RLE, _TPolygonSegmentation + +PYTHON_VERSION: Incomplete + + +class COCO: + anns: dict[int, _Annotation] + dataset: _Dataset + cats: dict[int, _Category] + imgs: dict[int, _Image] + imgToAnns: dict[int, list[_Annotation]] + catToImgs: dict[int, list[int]] + def __init__(self, annotation_file: str | Path = ...) -> None: ... + def createIndex(self) -> None: ... + def info(self) -> None: ... + def getAnnIds(self, imgIds: list[int] = ..., catIds: list[int] = ..., areaRng: list[float] = ..., iscrowd: bool | None = ...) -> list[int]: ... + def getCatIds(self, catNms: list[str] = ..., supNms: list[str] = ..., catIds: list[int] = ...) -> list[int]: ... + def getImgIds(self, imgIds: list[int] = ..., catIds: list[int] = ...) -> list[int]: ... + def loadAnns(self, ids: list[int] = ...) -> list[_Annotation]: ... + def loadCats(self, ids: list[int] = ...) -> list[_Category]: ... + def loadImgs(self, ids: list[int] = ...) -> list[_Image]: ... + def showAnns(self, anns: list[_Annotation], draw_bbox: bool = ...) -> None: ... + def loadRes(self, resFile: str) -> Self: ... + def download(self, tarDir: str | None = ..., imgIds: list[int] = ...) -> Literal[-1] | None: ... + def loadNumpyAnnotations(self, data: npt.NDArray[np.float64]) -> list[_Annotation]: ... + @overload + def annToRLE(self, ann: _AnnotationG[_RLE]) -> _RLE: ... + @overload + def annToRLE(self, ann: _AnnotationG[_EncodedRLE]) -> _EncodedRLE: ... + @overload + def annToRLE(self, ann: _AnnotationG[_TPolygonSegmentation]) -> _EncodedRLE: ... + def annToMask(self, ann: _Annotation) -> npt.NDArray[np.uint8]: ... diff --git a/stubs/pycocotools/pycocotools/coco_types.pyi b/stubs/pycocotools/pycocotools/coco_types.pyi new file mode 100644 index 000000000000..d290966033b8 --- /dev/null +++ b/stubs/pycocotools/pycocotools/coco_types.pyi @@ -0,0 +1,72 @@ +from typing import Generic, TypeAlias, TypedDict, TypeVar + +import numpy as np +import numpy.typing as npt + +class _Image(TypedDict): + id: int + width: int + height: int + file_name: str + + +_TPolygonSegmentation: TypeAlias = list[list[float]] + + +class _RLE(TypedDict): + size: list[int] + counts: list[int] + + +class _EncodedRLE(TypedDict): + size: list[int] + counts: str | bytes + + +class _Annotation(TypedDict): + id: int + image_id: int + category_id: int + segmentation: _TPolygonSegmentation | _RLE | _EncodedRLE + area: float + bbox: list[float] + iscrowd: int # Either 1 or 0 + + +_TSeg = TypeVar("_TSeg", _TPolygonSegmentation, _RLE, _EncodedRLE) + + +class _AnnotationG(TypedDict, Generic[_TSeg]): + id: int + image_id: int + category_id: int + segmentation: _TSeg + area: float + bbox: list[float] + iscrowd: int # Either 1 or 0 + + +class _Category(TypedDict): + id: int + name: str + supercategory: str + + +class _EvaluationResult(TypedDict): + image_id: int + category_id: int + aRng: list[int] + maxDet: int + dtIds: list[int] + gtIds: list[int] + dtMatches: npt.NDArray[np.float64] + gtMatches: npt.NDArray[np.float64] + dtScores: list[float] + gtIgnore: npt.NDArray[np.float64] + dtIgnore: npt.NDArray[np.float64] + + +class Dataset(TypedDict): + images: list[Image] + annotations: list[Annotation] + categories: list[Category] From 2a1c2513a857bf1678035ffd9d3de22fa389a581 Mon Sep 17 00:00:00 2001 From: Hoel Bagard Date: Fri, 4 Nov 2022 12:16:12 +0900 Subject: [PATCH 02/32] Added the mask.pyi file. --- stubs/pycocotools/pycocotools/coco_types.pyi | 6 +++--- stubs/pycocotools/pycocotools/mask.pyi | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 stubs/pycocotools/pycocotools/mask.pyi diff --git a/stubs/pycocotools/pycocotools/coco_types.pyi b/stubs/pycocotools/pycocotools/coco_types.pyi index d290966033b8..582ae500adac 100644 --- a/stubs/pycocotools/pycocotools/coco_types.pyi +++ b/stubs/pycocotools/pycocotools/coco_types.pyi @@ -67,6 +67,6 @@ class _EvaluationResult(TypedDict): class Dataset(TypedDict): - images: list[Image] - annotations: list[Annotation] - categories: list[Category] + images: list[_Image] + annotations: list[_Annotation] + categories: list[_Category] diff --git a/stubs/pycocotools/pycocotools/mask.pyi b/stubs/pycocotools/pycocotools/mask.pyi new file mode 100644 index 000000000000..6a7b98bb64f9 --- /dev/null +++ b/stubs/pycocotools/pycocotools/mask.pyi @@ -0,0 +1,18 @@ +from typing import overload + +import numpy as np +import numpy.typing as npt + +from .coco_types import _EncodedRLE + + +def iou(dt: npt.NDArray[np.uint32] | list[float] | list[_EncodedRLE], gt: npt.NDArray[np.uint32] | list[float] | list[_EncodedRLE], pyiscrowd: list[int] | npt.NDArray[np.uint8]) -> list | npt.NDArray[np.float64]: ... +def merge(rleObjs: list[_EncodedRLE], intersect: int = ...): ... +@overload +def frPyObjects(pyobj: npt.NDArray[np.uint32] | list[list[int]] | list[_EncodedRLE], h: int, w: int) -> list[_EncodedRLE]: ... +@overload +def frPyObjects(pyobj: list[int] | _EncodedRLE, h: int, w: int) -> _EncodedRLE: ... +def encode(bimask: npt.NDArray[np.uint8]) -> _EncodedRLE: ... +def decode(rleObjs: _EncodedRLE) -> npt.NDArray[np.uint8]: ... +def area(rleObjs: _EncodedRLE) -> np.uint32: ... +def toBbox(rleObjs: _EncodedRLE) -> npt.NDArray[np.float64]: ... From 81675f96ff4f4eed1b025f74e875042a15d5b5a5 Mon Sep 17 00:00:00 2001 From: Hoel Bagard Date: Fri, 4 Nov 2022 12:48:42 +0900 Subject: [PATCH 03/32] Added the cocoeval.pyi file. --- stubs/pycocotools/METADATA.toml | 4 +++ stubs/pycocotools/pycocotools/cocoeval.pyi | 42 ++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 stubs/pycocotools/METADATA.toml create mode 100644 stubs/pycocotools/pycocotools/cocoeval.pyi diff --git a/stubs/pycocotools/METADATA.toml b/stubs/pycocotools/METADATA.toml new file mode 100644 index 000000000000..424bb5bd8834 --- /dev/null +++ b/stubs/pycocotools/METADATA.toml @@ -0,0 +1,4 @@ +version = "2.0.*" + +[tool.stubtest] +ignore_missing_stub = false diff --git a/stubs/pycocotools/pycocotools/cocoeval.pyi b/stubs/pycocotools/pycocotools/cocoeval.pyi new file mode 100644 index 000000000000..b10c9f5b5ca2 --- /dev/null +++ b/stubs/pycocotools/pycocotools/cocoeval.pyi @@ -0,0 +1,42 @@ +from typing import Literal, Optional, TypeAlias + +import numpy as np +import numpy.typing as npt + +from .coco import COCO +from .coco_types import _EvaluationResult + +_TIOU: TypeAlias = Literal["segm", "bbox", "keypoints"] + + +class COCOeval: + cocoGt: COCO + cocoDt: COCO + evalImgs: list[_EvaluationResult] + eval: _EvaluationResult + params: Params + stats: npt.NDArray[np.float64] + ious: dict[tuple[int, int], list[float]] + def __init__(self, cocoGt: COCO | None = ..., cocoDt: COCO | None = ..., iouType: _TIOU = ...) -> None: ... + def evaluate(self) -> None: ... + def computeIoU(self, imgId: int, catId: int) -> list[float]: ... + def computeOks(self, imgId: int, catId: int) -> npt.NDArray[np.float64]: ... + def evaluateImg(self, imgId: int, catId: int, aRng: list[int], maxDet: int) -> _EvaluationResult: ... + def accumulate(self, p: Params | None = ...) -> None: ... + def summarize(self) -> None: ... + +class Params: + imgIds: list[int] + catIds: list[int] + iouThrs: npt.NDArray[np.float64] + recThrs: npt.NDArray[np.float64] + maxDets: list[int] + areaRng: list[int] + areaRngLbl: list[str] + useCats: int + kpt_oks_sigmas: npt.NDArray[np.float64] + iouType: _TIOU + useSegm: int | None + def __init__(self, iouType: _TIOU = ...) -> None: ... + def setDetParams(self) -> None: ... + def setKpParams(self) -> None: ... From 07febd5586cdb9d6e1df5751de10e6a1b12cf036 Mon Sep 17 00:00:00 2001 From: Hoel Bagard Date: Fri, 4 Nov 2022 12:56:48 +0900 Subject: [PATCH 04/32] Added imports to the __init__. --- stubs/pycocotools/pycocotools/__init__.pyi | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stubs/pycocotools/pycocotools/__init__.pyi b/stubs/pycocotools/pycocotools/__init__.pyi index e69de29bb2d1..2db6da3b4e20 100644 --- a/stubs/pycocotools/pycocotools/__init__.pyi +++ b/stubs/pycocotools/pycocotools/__init__.pyi @@ -0,0 +1,3 @@ +from .mask import * +from .coco import * +from .cocoeval import * From 4faa515641f76a1952776616e352d5d8f42f6ac8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 4 Nov 2022 04:08:36 +0000 Subject: [PATCH 05/32] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/pycocotools/pycocotools/__init__.pyi | 2 +- stubs/pycocotools/pycocotools/coco.pyi | 11 ++++++----- stubs/pycocotools/pycocotools/coco_types.pyi | 9 --------- stubs/pycocotools/pycocotools/cocoeval.pyi | 5 ++--- stubs/pycocotools/pycocotools/mask.pyi | 7 +++++-- 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/stubs/pycocotools/pycocotools/__init__.pyi b/stubs/pycocotools/pycocotools/__init__.pyi index 2db6da3b4e20..c33223ae09b0 100644 --- a/stubs/pycocotools/pycocotools/__init__.pyi +++ b/stubs/pycocotools/pycocotools/__init__.pyi @@ -1,3 +1,3 @@ -from .mask import * from .coco import * from .cocoeval import * +from .mask import * diff --git a/stubs/pycocotools/pycocotools/coco.pyi b/stubs/pycocotools/pycocotools/coco.pyi index c7e6c8d3ad9f..dc50fb1e43ad 100644 --- a/stubs/pycocotools/pycocotools/coco.pyi +++ b/stubs/pycocotools/pycocotools/coco.pyi @@ -1,16 +1,15 @@ +from _typeshed import Incomplete from pathlib import Path from typing import Literal, overload +from typing_extensions import Self import numpy as np import numpy.typing as npt -from _typeshed import Incomplete -from typing_extensions import Self -from .coco_types import _Annotation, _AnnotationG, _Category, _Dataset, _EncodedRLE, _Image, _RLE, _TPolygonSegmentation +from .coco_types import _RLE, _Annotation, _AnnotationG, _Category, _Dataset, _EncodedRLE, _Image, _TPolygonSegmentation PYTHON_VERSION: Incomplete - class COCO: anns: dict[int, _Annotation] dataset: _Dataset @@ -21,7 +20,9 @@ class COCO: def __init__(self, annotation_file: str | Path = ...) -> None: ... def createIndex(self) -> None: ... def info(self) -> None: ... - def getAnnIds(self, imgIds: list[int] = ..., catIds: list[int] = ..., areaRng: list[float] = ..., iscrowd: bool | None = ...) -> list[int]: ... + def getAnnIds( + self, imgIds: list[int] = ..., catIds: list[int] = ..., areaRng: list[float] = ..., iscrowd: bool | None = ... + ) -> list[int]: ... def getCatIds(self, catNms: list[str] = ..., supNms: list[str] = ..., catIds: list[int] = ...) -> list[int]: ... def getImgIds(self, imgIds: list[int] = ..., catIds: list[int] = ...) -> list[int]: ... def loadAnns(self, ids: list[int] = ...) -> list[_Annotation]: ... diff --git a/stubs/pycocotools/pycocotools/coco_types.pyi b/stubs/pycocotools/pycocotools/coco_types.pyi index 582ae500adac..f25cbe17434d 100644 --- a/stubs/pycocotools/pycocotools/coco_types.pyi +++ b/stubs/pycocotools/pycocotools/coco_types.pyi @@ -9,20 +9,16 @@ class _Image(TypedDict): height: int file_name: str - _TPolygonSegmentation: TypeAlias = list[list[float]] - class _RLE(TypedDict): size: list[int] counts: list[int] - class _EncodedRLE(TypedDict): size: list[int] counts: str | bytes - class _Annotation(TypedDict): id: int image_id: int @@ -32,10 +28,8 @@ class _Annotation(TypedDict): bbox: list[float] iscrowd: int # Either 1 or 0 - _TSeg = TypeVar("_TSeg", _TPolygonSegmentation, _RLE, _EncodedRLE) - class _AnnotationG(TypedDict, Generic[_TSeg]): id: int image_id: int @@ -45,13 +39,11 @@ class _AnnotationG(TypedDict, Generic[_TSeg]): bbox: list[float] iscrowd: int # Either 1 or 0 - class _Category(TypedDict): id: int name: str supercategory: str - class _EvaluationResult(TypedDict): image_id: int category_id: int @@ -65,7 +57,6 @@ class _EvaluationResult(TypedDict): gtIgnore: npt.NDArray[np.float64] dtIgnore: npt.NDArray[np.float64] - class Dataset(TypedDict): images: list[_Image] annotations: list[_Annotation] diff --git a/stubs/pycocotools/pycocotools/cocoeval.pyi b/stubs/pycocotools/pycocotools/cocoeval.pyi index b10c9f5b5ca2..c579d7b5444a 100644 --- a/stubs/pycocotools/pycocotools/cocoeval.pyi +++ b/stubs/pycocotools/pycocotools/cocoeval.pyi @@ -1,4 +1,4 @@ -from typing import Literal, Optional, TypeAlias +from typing import Literal, TypeAlias import numpy as np import numpy.typing as npt @@ -8,7 +8,6 @@ from .coco_types import _EvaluationResult _TIOU: TypeAlias = Literal["segm", "bbox", "keypoints"] - class COCOeval: cocoGt: COCO cocoDt: COCO @@ -16,7 +15,7 @@ class COCOeval: eval: _EvaluationResult params: Params stats: npt.NDArray[np.float64] - ious: dict[tuple[int, int], list[float]] + ious: dict[tuple[int, int], list[float]] def __init__(self, cocoGt: COCO | None = ..., cocoDt: COCO | None = ..., iouType: _TIOU = ...) -> None: ... def evaluate(self) -> None: ... def computeIoU(self, imgId: int, catId: int) -> list[float]: ... diff --git a/stubs/pycocotools/pycocotools/mask.pyi b/stubs/pycocotools/pycocotools/mask.pyi index 6a7b98bb64f9..87d3d62df2fa 100644 --- a/stubs/pycocotools/pycocotools/mask.pyi +++ b/stubs/pycocotools/pycocotools/mask.pyi @@ -5,8 +5,11 @@ import numpy.typing as npt from .coco_types import _EncodedRLE - -def iou(dt: npt.NDArray[np.uint32] | list[float] | list[_EncodedRLE], gt: npt.NDArray[np.uint32] | list[float] | list[_EncodedRLE], pyiscrowd: list[int] | npt.NDArray[np.uint8]) -> list | npt.NDArray[np.float64]: ... +def iou( + dt: npt.NDArray[np.uint32] | list[float] | list[_EncodedRLE], + gt: npt.NDArray[np.uint32] | list[float] | list[_EncodedRLE], + pyiscrowd: list[int] | npt.NDArray[np.uint8], +) -> list | npt.NDArray[np.float64]: ... def merge(rleObjs: list[_EncodedRLE], intersect: int = ...): ... @overload def frPyObjects(pyobj: npt.NDArray[np.uint32] | list[list[int]] | list[_EncodedRLE], h: int, w: int) -> list[_EncodedRLE]: ... From 3fe497dd2139f75ed5b280bb3367c1e3b9f224aa Mon Sep 17 00:00:00 2001 From: Hoel Bagard Date: Fri, 4 Nov 2022 14:49:14 +0900 Subject: [PATCH 06/32] Fixed some ids being allowed to also be simple int/str instead of list. --- stubs/pycocotools/pycocotools/coco.pyi | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/stubs/pycocotools/pycocotools/coco.pyi b/stubs/pycocotools/pycocotools/coco.pyi index c7e6c8d3ad9f..ffeca0856ffa 100644 --- a/stubs/pycocotools/pycocotools/coco.pyi +++ b/stubs/pycocotools/pycocotools/coco.pyi @@ -21,12 +21,12 @@ class COCO: def __init__(self, annotation_file: str | Path = ...) -> None: ... def createIndex(self) -> None: ... def info(self) -> None: ... - def getAnnIds(self, imgIds: list[int] = ..., catIds: list[int] = ..., areaRng: list[float] = ..., iscrowd: bool | None = ...) -> list[int]: ... - def getCatIds(self, catNms: list[str] = ..., supNms: list[str] = ..., catIds: list[int] = ...) -> list[int]: ... - def getImgIds(self, imgIds: list[int] = ..., catIds: list[int] = ...) -> list[int]: ... - def loadAnns(self, ids: list[int] = ...) -> list[_Annotation]: ... - def loadCats(self, ids: list[int] = ...) -> list[_Category]: ... - def loadImgs(self, ids: list[int] = ...) -> list[_Image]: ... + def getAnnIds(self, imgIds: list[int] | int = ..., catIds: list[int] | int = ..., areaRng: list[float] = ..., iscrowd: bool | None = ...) -> list[int]: ... + def getCatIds(self, catNms: list[str] | str = ..., supNms: list[str] | str = ..., catIds: list[int] | int = ...) -> list[int]: ... + def getImgIds(self, imgIds: list[int] | int = ..., catIds: list[int] | int = ...) -> list[int]: ... + def loadAnns(self, ids: list[int] | int = ...) -> list[_Annotation]: ... + def loadCats(self, ids: list[int] | int = ...) -> list[_Category]: ... + def loadImgs(self, ids: list[int] | int = ...) -> list[_Image]: ... def showAnns(self, anns: list[_Annotation], draw_bbox: bool = ...) -> None: ... def loadRes(self, resFile: str) -> Self: ... def download(self, tarDir: str | None = ..., imgIds: list[int] = ...) -> Literal[-1] | None: ... From 87039a79afc6375d08682e250ef67b2c44079c5a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 4 Nov 2022 05:52:03 +0000 Subject: [PATCH 07/32] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/pycocotools/pycocotools/coco.pyi | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/stubs/pycocotools/pycocotools/coco.pyi b/stubs/pycocotools/pycocotools/coco.pyi index 94a2ed7e7a73..093875501f5e 100644 --- a/stubs/pycocotools/pycocotools/coco.pyi +++ b/stubs/pycocotools/pycocotools/coco.pyi @@ -21,9 +21,11 @@ class COCO: def createIndex(self) -> None: ... def info(self) -> None: ... def getAnnIds( - self, imgIds: list[int] | int = ..., catIds: list[int] | int = ..., areaRng: list[float] = ..., iscrowd: bool | None = ... + self, imgIds: list[int] | int = ..., catIds: list[int] | int = ..., areaRng: list[float] = ..., iscrowd: bool | None = ... + ) -> list[int]: ... + def getCatIds( + self, catNms: list[str] | str = ..., supNms: list[str] | str = ..., catIds: list[int] | int = ... ) -> list[int]: ... - def getCatIds(self, catNms: list[str] | str = ..., supNms: list[str] | str = ..., catIds: list[int] | int = ...) -> list[int]: ... def getImgIds(self, imgIds: list[int] | int = ..., catIds: list[int] | int = ...) -> list[int]: ... def loadAnns(self, ids: list[int] | int = ...) -> list[_Annotation]: ... def loadCats(self, ids: list[int] | int = ...) -> list[_Category]: ... From feb9114b22cbde1431e84a7bc89e888d4d0b924a Mon Sep 17 00:00:00 2001 From: Hoel Bagard Date: Fri, 4 Nov 2022 16:21:51 +0900 Subject: [PATCH 08/32] Fixed name missing an '_' --- stubs/pycocotools/pycocotools/coco_types.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/pycocotools/pycocotools/coco_types.pyi b/stubs/pycocotools/pycocotools/coco_types.pyi index f25cbe17434d..ad131e69d1d9 100644 --- a/stubs/pycocotools/pycocotools/coco_types.pyi +++ b/stubs/pycocotools/pycocotools/coco_types.pyi @@ -57,7 +57,7 @@ class _EvaluationResult(TypedDict): gtIgnore: npt.NDArray[np.float64] dtIgnore: npt.NDArray[np.float64] -class Dataset(TypedDict): +class _Dataset(TypedDict): images: list[_Image] annotations: list[_Annotation] categories: list[_Category] From f03e88cab6a453cccbd354e7d5d0b226d5bbf800 Mon Sep 17 00:00:00 2001 From: Hoel Bagard Date: Fri, 4 Nov 2022 18:39:04 +0900 Subject: [PATCH 09/32] Moved some imports from typing to typing_extensions. --- stubs/pycocotools/pycocotools/coco.pyi | 4 ++-- stubs/pycocotools/pycocotools/coco_types.pyi | 3 ++- stubs/pycocotools/pycocotools/cocoeval.pyi | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/stubs/pycocotools/pycocotools/coco.pyi b/stubs/pycocotools/pycocotools/coco.pyi index 093875501f5e..7120627b02ef 100644 --- a/stubs/pycocotools/pycocotools/coco.pyi +++ b/stubs/pycocotools/pycocotools/coco.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete from pathlib import Path -from typing import Literal, overload -from typing_extensions import Self +from typing import overload +from typing_extensions import Literal, Self import numpy as np import numpy.typing as npt diff --git a/stubs/pycocotools/pycocotools/coco_types.pyi b/stubs/pycocotools/pycocotools/coco_types.pyi index ad131e69d1d9..fcd0de8eaaa6 100644 --- a/stubs/pycocotools/pycocotools/coco_types.pyi +++ b/stubs/pycocotools/pycocotools/coco_types.pyi @@ -1,4 +1,5 @@ -from typing import Generic, TypeAlias, TypedDict, TypeVar +from typing import Generic, TypeAlias, TypeVar +from typing_extensions import TypedDict import numpy as np import numpy.typing as npt diff --git a/stubs/pycocotools/pycocotools/cocoeval.pyi b/stubs/pycocotools/pycocotools/cocoeval.pyi index c579d7b5444a..9a950a8e3308 100644 --- a/stubs/pycocotools/pycocotools/cocoeval.pyi +++ b/stubs/pycocotools/pycocotools/cocoeval.pyi @@ -1,4 +1,5 @@ -from typing import Literal, TypeAlias +from typing import TypeAlias +from typing_extensions import Literal import numpy as np import numpy.typing as npt From 8aca487d73fbfe259568400e032ce7393c165346 Mon Sep 17 00:00:00 2001 From: Hoel Bagard Date: Fri, 4 Nov 2022 19:01:25 +0900 Subject: [PATCH 10/32] Removed numpy dependency. --- stubs/pycocotools/pycocotools/coco.pyi | 13 +++++---- stubs/pycocotools/pycocotools/coco_types.pyi | 19 +++++++++---- stubs/pycocotools/pycocotools/cocoeval.pyi | 24 ++++++++++------ stubs/pycocotools/pycocotools/mask.pyi | 30 +++++++++++++------- 4 files changed, 55 insertions(+), 31 deletions(-) diff --git a/stubs/pycocotools/pycocotools/coco.pyi b/stubs/pycocotools/pycocotools/coco.pyi index 7120627b02ef..9f553b29f22b 100644 --- a/stubs/pycocotools/pycocotools/coco.pyi +++ b/stubs/pycocotools/pycocotools/coco.pyi @@ -1,14 +1,15 @@ from _typeshed import Incomplete from pathlib import Path from typing import overload -from typing_extensions import Literal, Self +from typing_extensions import Literal, Self, TypeAlias -import numpy as np -import numpy.typing as npt +# import numpy as np +# import numpy.typing as npt from .coco_types import _RLE, _Annotation, _AnnotationG, _Category, _Dataset, _EncodedRLE, _Image, _TPolygonSegmentation PYTHON_VERSION: Incomplete +_NDArray: TypeAlias = Incomplete class COCO: anns: dict[int, _Annotation] @@ -33,11 +34,13 @@ class COCO: def showAnns(self, anns: list[_Annotation], draw_bbox: bool = ...) -> None: ... def loadRes(self, resFile: str) -> Self: ... def download(self, tarDir: str | None = ..., imgIds: list[int] = ...) -> Literal[-1] | None: ... - def loadNumpyAnnotations(self, data: npt.NDArray[np.float64]) -> list[_Annotation]: ... + def loadNumpyAnnotations(self, data: _NDArray) -> list[_Annotation]: ... + # def loadNumpyAnnotations(self, data: npt._NDArray[np.float64]) -> list[_Annotation]: ... @overload def annToRLE(self, ann: _AnnotationG[_RLE]) -> _RLE: ... @overload def annToRLE(self, ann: _AnnotationG[_EncodedRLE]) -> _EncodedRLE: ... @overload def annToRLE(self, ann: _AnnotationG[_TPolygonSegmentation]) -> _EncodedRLE: ... - def annToMask(self, ann: _Annotation) -> npt.NDArray[np.uint8]: ... + def annToMask(self, ann: _Annotation) -> _NDArray: ... + # def annToMask(self, ann: _Annotation) -> npt._NDArray[np.uint8]: ... diff --git a/stubs/pycocotools/pycocotools/coco_types.pyi b/stubs/pycocotools/pycocotools/coco_types.pyi index fcd0de8eaaa6..0c445391d197 100644 --- a/stubs/pycocotools/pycocotools/coco_types.pyi +++ b/stubs/pycocotools/pycocotools/coco_types.pyi @@ -1,8 +1,11 @@ +from _typeshed import Incomplete from typing import Generic, TypeAlias, TypeVar from typing_extensions import TypedDict -import numpy as np -import numpy.typing as npt +# import numpy as np +# import numpy.typing as npt + +_NDArray: TypeAlias = Incomplete class _Image(TypedDict): id: int @@ -52,11 +55,15 @@ class _EvaluationResult(TypedDict): maxDet: int dtIds: list[int] gtIds: list[int] - dtMatches: npt.NDArray[np.float64] - gtMatches: npt.NDArray[np.float64] + dtMatches: _NDArray + # dtMatches: npt._NDArray[np.float64] + gtMatches: _NDArray + # gtMatches: npt._NDArray[np.float64] dtScores: list[float] - gtIgnore: npt.NDArray[np.float64] - dtIgnore: npt.NDArray[np.float64] + gtIgnore: _NDArray + # gtIgnore: npt._NDArray[np.float64] + dtIgnore: _NDArray + # dtIgnore: npt._NDArray[np.float64] class _Dataset(TypedDict): images: list[_Image] diff --git a/stubs/pycocotools/pycocotools/cocoeval.pyi b/stubs/pycocotools/pycocotools/cocoeval.pyi index 9a950a8e3308..64919f6ba0e1 100644 --- a/stubs/pycocotools/pycocotools/cocoeval.pyi +++ b/stubs/pycocotools/pycocotools/cocoeval.pyi @@ -1,12 +1,13 @@ -from typing import TypeAlias -from typing_extensions import Literal +from _typeshed import Incomplete +from typing_extensions import Literal, TypeAlias -import numpy as np -import numpy.typing as npt +# import numpy as np +# import numpy.typing as npt from .coco import COCO from .coco_types import _EvaluationResult +_NDArray: TypeAlias = Incomplete _TIOU: TypeAlias = Literal["segm", "bbox", "keypoints"] class COCOeval: @@ -15,12 +16,14 @@ class COCOeval: evalImgs: list[_EvaluationResult] eval: _EvaluationResult params: Params - stats: npt.NDArray[np.float64] + stats: _NDArray + # stats: npt._NDArray[np.float64] ious: dict[tuple[int, int], list[float]] def __init__(self, cocoGt: COCO | None = ..., cocoDt: COCO | None = ..., iouType: _TIOU = ...) -> None: ... def evaluate(self) -> None: ... def computeIoU(self, imgId: int, catId: int) -> list[float]: ... - def computeOks(self, imgId: int, catId: int) -> npt.NDArray[np.float64]: ... + def computeOks(self, imgId: int, catId: int) -> _NDArray: ... + # def computeOks(self, imgId: int, catId: int) -> npt._NDArray[np.float64]: ... def evaluateImg(self, imgId: int, catId: int, aRng: list[int], maxDet: int) -> _EvaluationResult: ... def accumulate(self, p: Params | None = ...) -> None: ... def summarize(self) -> None: ... @@ -28,13 +31,16 @@ class COCOeval: class Params: imgIds: list[int] catIds: list[int] - iouThrs: npt.NDArray[np.float64] - recThrs: npt.NDArray[np.float64] + iouThrs: _NDArray + # iouThrs: npt._NDArray[np.float64] + recThrs: _NDArray + # recThrs: npt._NDArray[np.float64] maxDets: list[int] areaRng: list[int] areaRngLbl: list[str] useCats: int - kpt_oks_sigmas: npt.NDArray[np.float64] + kpt_oks_sigmas: _NDArray + # kpt_oks_sigmas: npt._NDArray[np.float64] iouType: _TIOU useSegm: int | None def __init__(self, iouType: _TIOU = ...) -> None: ... diff --git a/stubs/pycocotools/pycocotools/mask.pyi b/stubs/pycocotools/pycocotools/mask.pyi index 87d3d62df2fa..f79f74cb480c 100644 --- a/stubs/pycocotools/pycocotools/mask.pyi +++ b/stubs/pycocotools/pycocotools/mask.pyi @@ -1,21 +1,29 @@ +from _typeshed import Incomplete from typing import overload +from typing_extensions import Literal, TypeAlias -import numpy as np -import numpy.typing as npt +# import numpy as np +# import numpy.typing as npt from .coco_types import _EncodedRLE +_NPUInt32: TypeAlias = Incomplete # np.uint32 +_NDArrayUInt8: TypeAlias = Incomplete # npt._NDArray[np.uint8] +_NDArrayUInt32: TypeAlias = Incomplete # npt._NDArray[np.uint32] +_NDArrayFloat64: TypeAlias = Incomplete # npt._NDArray[np.float64] + def iou( - dt: npt.NDArray[np.uint32] | list[float] | list[_EncodedRLE], - gt: npt.NDArray[np.uint32] | list[float] | list[_EncodedRLE], - pyiscrowd: list[int] | npt.NDArray[np.uint8], -) -> list | npt.NDArray[np.float64]: ... + dt: _NDArrayUInt32 | list[float] | list[_EncodedRLE], + gt: _NDArrayUInt32 | list[float] | list[_EncodedRLE], + pyiscrowd: list[int] | _NDArrayUInt8, +) -> list | _NDArrayFloat64: ... def merge(rleObjs: list[_EncodedRLE], intersect: int = ...): ... @overload -def frPyObjects(pyobj: npt.NDArray[np.uint32] | list[list[int]] | list[_EncodedRLE], h: int, w: int) -> list[_EncodedRLE]: ... +def frPyObjects(pyobj: _NDArrayUInt32 | list[list[int]] | list[_EncodedRLE], h: int, w: int) -> list[_EncodedRLE]: ... +def frPyObjects(pyobj: _NDArrayUInt32 | list[list[int]] | list[_EncodedRLE], h: int, w: int) -> list[_EncodedRLE]: ... @overload def frPyObjects(pyobj: list[int] | _EncodedRLE, h: int, w: int) -> _EncodedRLE: ... -def encode(bimask: npt.NDArray[np.uint8]) -> _EncodedRLE: ... -def decode(rleObjs: _EncodedRLE) -> npt.NDArray[np.uint8]: ... -def area(rleObjs: _EncodedRLE) -> np.uint32: ... -def toBbox(rleObjs: _EncodedRLE) -> npt.NDArray[np.float64]: ... +def encode(bimask: _NDArrayUInt8) -> _EncodedRLE: ... +def decode(rleObjs: _EncodedRLE) -> _NDArrayUInt8: ... +def area(rleObjs: _EncodedRLE) -> _NPUInt32: ... +def toBbox(rleObjs: _EncodedRLE) -> _NDArrayFloat64: ... From a8cd2d5f702c79e9240d221822ebd83b2d90d1f0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 4 Nov 2022 10:02:39 +0000 Subject: [PATCH 11/32] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/pycocotools/pycocotools/coco.pyi | 3 ++- stubs/pycocotools/pycocotools/cocoeval.pyi | 5 +++-- stubs/pycocotools/pycocotools/mask.pyi | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/stubs/pycocotools/pycocotools/coco.pyi b/stubs/pycocotools/pycocotools/coco.pyi index 9f553b29f22b..02b5574ac743 100644 --- a/stubs/pycocotools/pycocotools/coco.pyi +++ b/stubs/pycocotools/pycocotools/coco.pyi @@ -3,10 +3,11 @@ from pathlib import Path from typing import overload from typing_extensions import Literal, Self, TypeAlias +from .coco_types import _RLE, _Annotation, _AnnotationG, _Category, _Dataset, _EncodedRLE, _Image, _TPolygonSegmentation + # import numpy as np # import numpy.typing as npt -from .coco_types import _RLE, _Annotation, _AnnotationG, _Category, _Dataset, _EncodedRLE, _Image, _TPolygonSegmentation PYTHON_VERSION: Incomplete _NDArray: TypeAlias = Incomplete diff --git a/stubs/pycocotools/pycocotools/cocoeval.pyi b/stubs/pycocotools/pycocotools/cocoeval.pyi index 64919f6ba0e1..df0c5cdfd084 100644 --- a/stubs/pycocotools/pycocotools/cocoeval.pyi +++ b/stubs/pycocotools/pycocotools/cocoeval.pyi @@ -1,11 +1,12 @@ from _typeshed import Incomplete from typing_extensions import Literal, TypeAlias +from .coco import COCO +from .coco_types import _EvaluationResult + # import numpy as np # import numpy.typing as npt -from .coco import COCO -from .coco_types import _EvaluationResult _NDArray: TypeAlias = Incomplete _TIOU: TypeAlias = Literal["segm", "bbox", "keypoints"] diff --git a/stubs/pycocotools/pycocotools/mask.pyi b/stubs/pycocotools/pycocotools/mask.pyi index f79f74cb480c..40afb8f98769 100644 --- a/stubs/pycocotools/pycocotools/mask.pyi +++ b/stubs/pycocotools/pycocotools/mask.pyi @@ -1,11 +1,12 @@ from _typeshed import Incomplete from typing import overload -from typing_extensions import Literal, TypeAlias +from typing_extensions import TypeAlias + +from .coco_types import _EncodedRLE # import numpy as np # import numpy.typing as npt -from .coco_types import _EncodedRLE _NPUInt32: TypeAlias = Incomplete # np.uint32 _NDArrayUInt8: TypeAlias = Incomplete # npt._NDArray[np.uint8] From 8b52fcaca091248f462f3dbbbb38291d1c475c1f Mon Sep 17 00:00:00 2001 From: Hoel Bagard Date: Fri, 4 Nov 2022 19:06:46 +0900 Subject: [PATCH 12/32] Removed extra underscores. --- stubs/pycocotools/pycocotools/coco.pyi | 4 ++-- stubs/pycocotools/pycocotools/coco_types.pyi | 8 ++++---- stubs/pycocotools/pycocotools/cocoeval.pyi | 10 +++++----- stubs/pycocotools/pycocotools/mask.pyi | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/stubs/pycocotools/pycocotools/coco.pyi b/stubs/pycocotools/pycocotools/coco.pyi index 9f553b29f22b..f0866ace3aac 100644 --- a/stubs/pycocotools/pycocotools/coco.pyi +++ b/stubs/pycocotools/pycocotools/coco.pyi @@ -35,7 +35,7 @@ class COCO: def loadRes(self, resFile: str) -> Self: ... def download(self, tarDir: str | None = ..., imgIds: list[int] = ...) -> Literal[-1] | None: ... def loadNumpyAnnotations(self, data: _NDArray) -> list[_Annotation]: ... - # def loadNumpyAnnotations(self, data: npt._NDArray[np.float64]) -> list[_Annotation]: ... + # def loadNumpyAnnotations(self, data: npt.NDArray[np.float64]) -> list[_Annotation]: ... @overload def annToRLE(self, ann: _AnnotationG[_RLE]) -> _RLE: ... @overload @@ -43,4 +43,4 @@ class COCO: @overload def annToRLE(self, ann: _AnnotationG[_TPolygonSegmentation]) -> _EncodedRLE: ... def annToMask(self, ann: _Annotation) -> _NDArray: ... - # def annToMask(self, ann: _Annotation) -> npt._NDArray[np.uint8]: ... + # def annToMask(self, ann: _Annotation) -> npt.NDArray[np.uint8]: ... diff --git a/stubs/pycocotools/pycocotools/coco_types.pyi b/stubs/pycocotools/pycocotools/coco_types.pyi index 0c445391d197..d707081b3ae4 100644 --- a/stubs/pycocotools/pycocotools/coco_types.pyi +++ b/stubs/pycocotools/pycocotools/coco_types.pyi @@ -56,14 +56,14 @@ class _EvaluationResult(TypedDict): dtIds: list[int] gtIds: list[int] dtMatches: _NDArray - # dtMatches: npt._NDArray[np.float64] + # dtMatches: npt.NDArray[np.float64] gtMatches: _NDArray - # gtMatches: npt._NDArray[np.float64] + # gtMatches: npt.NDArray[np.float64] dtScores: list[float] gtIgnore: _NDArray - # gtIgnore: npt._NDArray[np.float64] + # gtIgnore: npt.NDArray[np.float64] dtIgnore: _NDArray - # dtIgnore: npt._NDArray[np.float64] + # dtIgnore: npt.NDArray[np.float64] class _Dataset(TypedDict): images: list[_Image] diff --git a/stubs/pycocotools/pycocotools/cocoeval.pyi b/stubs/pycocotools/pycocotools/cocoeval.pyi index 64919f6ba0e1..90be00773657 100644 --- a/stubs/pycocotools/pycocotools/cocoeval.pyi +++ b/stubs/pycocotools/pycocotools/cocoeval.pyi @@ -17,13 +17,13 @@ class COCOeval: eval: _EvaluationResult params: Params stats: _NDArray - # stats: npt._NDArray[np.float64] + # stats: npt.NDArray[np.float64] ious: dict[tuple[int, int], list[float]] def __init__(self, cocoGt: COCO | None = ..., cocoDt: COCO | None = ..., iouType: _TIOU = ...) -> None: ... def evaluate(self) -> None: ... def computeIoU(self, imgId: int, catId: int) -> list[float]: ... def computeOks(self, imgId: int, catId: int) -> _NDArray: ... - # def computeOks(self, imgId: int, catId: int) -> npt._NDArray[np.float64]: ... + # def computeOks(self, imgId: int, catId: int) -> npt.NDArray[np.float64]: ... def evaluateImg(self, imgId: int, catId: int, aRng: list[int], maxDet: int) -> _EvaluationResult: ... def accumulate(self, p: Params | None = ...) -> None: ... def summarize(self) -> None: ... @@ -32,15 +32,15 @@ class Params: imgIds: list[int] catIds: list[int] iouThrs: _NDArray - # iouThrs: npt._NDArray[np.float64] + # iouThrs: npt.NDArray[np.float64] recThrs: _NDArray - # recThrs: npt._NDArray[np.float64] + # recThrs: npt.NDArray[np.float64] maxDets: list[int] areaRng: list[int] areaRngLbl: list[str] useCats: int kpt_oks_sigmas: _NDArray - # kpt_oks_sigmas: npt._NDArray[np.float64] + # kpt_oks_sigmas: npt.NDArray[np.float64] iouType: _TIOU useSegm: int | None def __init__(self, iouType: _TIOU = ...) -> None: ... diff --git a/stubs/pycocotools/pycocotools/mask.pyi b/stubs/pycocotools/pycocotools/mask.pyi index f79f74cb480c..c84a0b2fa535 100644 --- a/stubs/pycocotools/pycocotools/mask.pyi +++ b/stubs/pycocotools/pycocotools/mask.pyi @@ -8,9 +8,9 @@ from typing_extensions import Literal, TypeAlias from .coco_types import _EncodedRLE _NPUInt32: TypeAlias = Incomplete # np.uint32 -_NDArrayUInt8: TypeAlias = Incomplete # npt._NDArray[np.uint8] -_NDArrayUInt32: TypeAlias = Incomplete # npt._NDArray[np.uint32] -_NDArrayFloat64: TypeAlias = Incomplete # npt._NDArray[np.float64] +_NDArrayUInt8: TypeAlias = Incomplete # npt.NDArray[np.uint8] +_NDArrayUInt32: TypeAlias = Incomplete # npt.NDArray[np.uint32] +_NDArrayFloat64: TypeAlias = Incomplete # npt.NDArray[np.float64] def iou( dt: _NDArrayUInt32 | list[float] | list[_EncodedRLE], From 294e1040b8ffc2028c5d46fe434f807cda2d1fbe Mon Sep 17 00:00:00 2001 From: Hoel Bagard Date: Fri, 4 Nov 2022 19:17:05 +0900 Subject: [PATCH 13/32] Fixed TypeAlias import. --- stubs/pycocotools/pycocotools/coco_types.pyi | 4 ++-- stubs/pycocotools/pycocotools/mask.pyi | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/stubs/pycocotools/pycocotools/coco_types.pyi b/stubs/pycocotools/pycocotools/coco_types.pyi index d707081b3ae4..73484560e861 100644 --- a/stubs/pycocotools/pycocotools/coco_types.pyi +++ b/stubs/pycocotools/pycocotools/coco_types.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete -from typing import Generic, TypeAlias, TypeVar -from typing_extensions import TypedDict +from typing import Generic, TypeVar +from typing_extensions import TypedDict, TypeAlias # import numpy as np # import numpy.typing as npt diff --git a/stubs/pycocotools/pycocotools/mask.pyi b/stubs/pycocotools/pycocotools/mask.pyi index 83bc2f3692e0..84af80635df3 100644 --- a/stubs/pycocotools/pycocotools/mask.pyi +++ b/stubs/pycocotools/pycocotools/mask.pyi @@ -21,7 +21,6 @@ def iou( def merge(rleObjs: list[_EncodedRLE], intersect: int = ...): ... @overload def frPyObjects(pyobj: _NDArrayUInt32 | list[list[int]] | list[_EncodedRLE], h: int, w: int) -> list[_EncodedRLE]: ... -def frPyObjects(pyobj: _NDArrayUInt32 | list[list[int]] | list[_EncodedRLE], h: int, w: int) -> list[_EncodedRLE]: ... @overload def frPyObjects(pyobj: list[int] | _EncodedRLE, h: int, w: int) -> _EncodedRLE: ... def encode(bimask: _NDArrayUInt8) -> _EncodedRLE: ... From 749bdfa7fad355247e5f0e0882819cc68794cd7d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 4 Nov 2022 10:18:48 +0000 Subject: [PATCH 14/32] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/pycocotools/pycocotools/coco.pyi | 1 - stubs/pycocotools/pycocotools/coco_types.pyi | 2 +- stubs/pycocotools/pycocotools/cocoeval.pyi | 1 - stubs/pycocotools/pycocotools/mask.pyi | 1 - 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/stubs/pycocotools/pycocotools/coco.pyi b/stubs/pycocotools/pycocotools/coco.pyi index 22aa4effdb9d..7c95a1f9ba41 100644 --- a/stubs/pycocotools/pycocotools/coco.pyi +++ b/stubs/pycocotools/pycocotools/coco.pyi @@ -8,7 +8,6 @@ from .coco_types import _RLE, _Annotation, _AnnotationG, _Category, _Dataset, _E # import numpy as np # import numpy.typing as npt - PYTHON_VERSION: Incomplete _NDArray: TypeAlias = Incomplete diff --git a/stubs/pycocotools/pycocotools/coco_types.pyi b/stubs/pycocotools/pycocotools/coco_types.pyi index 73484560e861..0851d690ab61 100644 --- a/stubs/pycocotools/pycocotools/coco_types.pyi +++ b/stubs/pycocotools/pycocotools/coco_types.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete from typing import Generic, TypeVar -from typing_extensions import TypedDict, TypeAlias +from typing_extensions import TypeAlias, TypedDict # import numpy as np # import numpy.typing as npt diff --git a/stubs/pycocotools/pycocotools/cocoeval.pyi b/stubs/pycocotools/pycocotools/cocoeval.pyi index 07032b7cda18..96523f880ceb 100644 --- a/stubs/pycocotools/pycocotools/cocoeval.pyi +++ b/stubs/pycocotools/pycocotools/cocoeval.pyi @@ -7,7 +7,6 @@ from .coco_types import _EvaluationResult # import numpy as np # import numpy.typing as npt - _NDArray: TypeAlias = Incomplete _TIOU: TypeAlias = Literal["segm", "bbox", "keypoints"] diff --git a/stubs/pycocotools/pycocotools/mask.pyi b/stubs/pycocotools/pycocotools/mask.pyi index 84af80635df3..d99e84a9c6e2 100644 --- a/stubs/pycocotools/pycocotools/mask.pyi +++ b/stubs/pycocotools/pycocotools/mask.pyi @@ -7,7 +7,6 @@ from .coco_types import _EncodedRLE # import numpy as np # import numpy.typing as npt - _NPUInt32: TypeAlias = Incomplete # np.uint32 _NDArrayUInt8: TypeAlias = Incomplete # npt.NDArray[np.uint8] _NDArrayUInt32: TypeAlias = Incomplete # npt.NDArray[np.uint32] From cd6001fd4f1063875c4d3beea812aa99cef0b273 Mon Sep 17 00:00:00 2001 From: Hoel Bagard Date: Fri, 4 Nov 2022 20:29:11 +0900 Subject: [PATCH 15/32] Now using the Self type from _typeshed. --- stubs/pycocotools/pycocotools/coco.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stubs/pycocotools/pycocotools/coco.pyi b/stubs/pycocotools/pycocotools/coco.pyi index 7c95a1f9ba41..3ee1e4e0aac8 100644 --- a/stubs/pycocotools/pycocotools/coco.pyi +++ b/stubs/pycocotools/pycocotools/coco.pyi @@ -1,7 +1,7 @@ -from _typeshed import Incomplete +from _typeshed import Incomplete, Self from pathlib import Path from typing import overload -from typing_extensions import Literal, Self, TypeAlias +from typing_extensions import Literal, TypeAlias from .coco_types import _RLE, _Annotation, _AnnotationG, _Category, _Dataset, _EncodedRLE, _Image, _TPolygonSegmentation @@ -32,7 +32,7 @@ class COCO: def loadCats(self, ids: list[int] | int = ...) -> list[_Category]: ... def loadImgs(self, ids: list[int] | int = ...) -> list[_Image]: ... def showAnns(self, anns: list[_Annotation], draw_bbox: bool = ...) -> None: ... - def loadRes(self, resFile: str) -> Self: ... + def loadRes(self: Self, resFile: str) -> Self: ... def download(self, tarDir: str | None = ..., imgIds: list[int] = ...) -> Literal[-1] | None: ... def loadNumpyAnnotations(self, data: _NDArray) -> list[_Annotation]: ... # def loadNumpyAnnotations(self, data: npt.NDArray[np.float64]) -> list[_Annotation]: ... From 95364954d83dd1192bc2cdbd761fb6af0450139c Mon Sep 17 00:00:00 2001 From: Hoel Bagard Date: Fri, 4 Nov 2022 20:32:33 +0900 Subject: [PATCH 16/32] Added references to #5768 next to the commented out numpy imports. --- stubs/pycocotools/pycocotools/coco.pyi | 1 + stubs/pycocotools/pycocotools/coco_types.pyi | 1 + stubs/pycocotools/pycocotools/cocoeval.pyi | 1 + stubs/pycocotools/pycocotools/mask.pyi | 1 + 4 files changed, 4 insertions(+) diff --git a/stubs/pycocotools/pycocotools/coco.pyi b/stubs/pycocotools/pycocotools/coco.pyi index 3ee1e4e0aac8..ae0dede170be 100644 --- a/stubs/pycocotools/pycocotools/coco.pyi +++ b/stubs/pycocotools/pycocotools/coco.pyi @@ -5,6 +5,7 @@ from typing_extensions import Literal, TypeAlias from .coco_types import _RLE, _Annotation, _AnnotationG, _Category, _Dataset, _EncodedRLE, _Image, _TPolygonSegmentation +# TODO: Use numpy types when #5768 is resolved. # import numpy as np # import numpy.typing as npt diff --git a/stubs/pycocotools/pycocotools/coco_types.pyi b/stubs/pycocotools/pycocotools/coco_types.pyi index 0851d690ab61..de97b724326d 100644 --- a/stubs/pycocotools/pycocotools/coco_types.pyi +++ b/stubs/pycocotools/pycocotools/coco_types.pyi @@ -2,6 +2,7 @@ from _typeshed import Incomplete from typing import Generic, TypeVar from typing_extensions import TypeAlias, TypedDict +# TODO: Use numpy types when #5768 is resolved. # import numpy as np # import numpy.typing as npt diff --git a/stubs/pycocotools/pycocotools/cocoeval.pyi b/stubs/pycocotools/pycocotools/cocoeval.pyi index 96523f880ceb..11c38dff7f89 100644 --- a/stubs/pycocotools/pycocotools/cocoeval.pyi +++ b/stubs/pycocotools/pycocotools/cocoeval.pyi @@ -4,6 +4,7 @@ from typing_extensions import Literal, TypeAlias from .coco import COCO from .coco_types import _EvaluationResult +# TODO: Use numpy types when #5768 is resolved. # import numpy as np # import numpy.typing as npt diff --git a/stubs/pycocotools/pycocotools/mask.pyi b/stubs/pycocotools/pycocotools/mask.pyi index d99e84a9c6e2..9f88c4307077 100644 --- a/stubs/pycocotools/pycocotools/mask.pyi +++ b/stubs/pycocotools/pycocotools/mask.pyi @@ -4,6 +4,7 @@ from typing_extensions import TypeAlias from .coco_types import _EncodedRLE +# TODO: Use numpy types when #5768 is resolved. # import numpy as np # import numpy.typing as npt From 5985956ba2c84408b261302a3279962f1ea8272b Mon Sep 17 00:00:00 2001 From: Hoel Bagard Date: Fri, 4 Nov 2022 20:33:56 +0900 Subject: [PATCH 17/32] Removed the pycocotools entry from pyrightconfig.stricter.json. --- pyrightconfig.stricter.json | 1 - 1 file changed, 1 deletion(-) diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index ce42fc92acaf..0ca5a6161116 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -59,7 +59,6 @@ "stubs/peewee", "stubs/psutil", "stubs/psycopg2", - "stubs/pycocotools", "stubs/pyflakes", "stubs/Pygments", "stubs/PyMySQL", From 980f3607a256e5600873eda50136299b93564734 Mon Sep 17 00:00:00 2001 From: Hoel Bagard Date: Fri, 4 Nov 2022 21:02:03 +0900 Subject: [PATCH 18/32] Added missing return type. --- stubs/pycocotools/pycocotools/mask.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stubs/pycocotools/pycocotools/mask.pyi b/stubs/pycocotools/pycocotools/mask.pyi index 9f88c4307077..ad4871c9bec4 100644 --- a/stubs/pycocotools/pycocotools/mask.pyi +++ b/stubs/pycocotools/pycocotools/mask.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from typing import overload +from typing import Any, overload from typing_extensions import TypeAlias from .coco_types import _EncodedRLE @@ -17,8 +17,8 @@ def iou( dt: _NDArrayUInt32 | list[float] | list[_EncodedRLE], gt: _NDArrayUInt32 | list[float] | list[_EncodedRLE], pyiscrowd: list[int] | _NDArrayUInt8, -) -> list | _NDArrayFloat64: ... -def merge(rleObjs: list[_EncodedRLE], intersect: int = ...): ... +) -> list[Any] | _NDArrayFloat64: ... +def merge(rleObjs: list[_EncodedRLE], intersect: int = ...) -> _EncodedRLE: ... @overload def frPyObjects(pyobj: _NDArrayUInt32 | list[list[int]] | list[_EncodedRLE], h: int, w: int) -> list[_EncodedRLE]: ... @overload From 5f09960dee51b73135ae8f983df99cd00d82a0dd Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 4 Nov 2022 22:06:01 +0000 Subject: [PATCH 19/32] Fix mypy error --- stubs/pycocotools/pycocotools/mask.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stubs/pycocotools/pycocotools/mask.pyi b/stubs/pycocotools/pycocotools/mask.pyi index ad4871c9bec4..91070690ac34 100644 --- a/stubs/pycocotools/pycocotools/mask.pyi +++ b/stubs/pycocotools/pycocotools/mask.pyi @@ -19,8 +19,9 @@ def iou( pyiscrowd: list[int] | _NDArrayUInt8, ) -> list[Any] | _NDArrayFloat64: ... def merge(rleObjs: list[_EncodedRLE], intersect: int = ...) -> _EncodedRLE: ... +# ignore an "overlapping overloads" error due to _NDArrayInt32 being an alias for `Incomplete` for now @overload -def frPyObjects(pyobj: _NDArrayUInt32 | list[list[int]] | list[_EncodedRLE], h: int, w: int) -> list[_EncodedRLE]: ... +def frPyObjects(pyobj: _NDArrayUInt32 | list[list[int]] | list[_EncodedRLE], h: int, w: int) -> list[_EncodedRLE]: ... # type: ignore[misc] @overload def frPyObjects(pyobj: list[int] | _EncodedRLE, h: int, w: int) -> _EncodedRLE: ... def encode(bimask: _NDArrayUInt8) -> _EncodedRLE: ... From 4a0bac0f5a3c48985bad423b7a81c20f3da97b3f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 4 Nov 2022 22:07:05 +0000 Subject: [PATCH 20/32] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/pycocotools/pycocotools/mask.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stubs/pycocotools/pycocotools/mask.pyi b/stubs/pycocotools/pycocotools/mask.pyi index 91070690ac34..585837c22db9 100644 --- a/stubs/pycocotools/pycocotools/mask.pyi +++ b/stubs/pycocotools/pycocotools/mask.pyi @@ -19,6 +19,7 @@ def iou( pyiscrowd: list[int] | _NDArrayUInt8, ) -> list[Any] | _NDArrayFloat64: ... def merge(rleObjs: list[_EncodedRLE], intersect: int = ...) -> _EncodedRLE: ... + # ignore an "overlapping overloads" error due to _NDArrayInt32 being an alias for `Incomplete` for now @overload def frPyObjects(pyobj: _NDArrayUInt32 | list[list[int]] | list[_EncodedRLE], h: int, w: int) -> list[_EncodedRLE]: ... # type: ignore[misc] From de905d215a83064211cb4c7b1ad347c6b7168133 Mon Sep 17 00:00:00 2001 From: Hoel Bagard Date: Sat, 5 Nov 2022 20:41:58 +0900 Subject: [PATCH 21/32] Added 'None' type to the COCO init arg as it is the default value. --- stubs/pycocotools/pycocotools/coco.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/pycocotools/pycocotools/coco.pyi b/stubs/pycocotools/pycocotools/coco.pyi index ae0dede170be..db5894a6a311 100644 --- a/stubs/pycocotools/pycocotools/coco.pyi +++ b/stubs/pycocotools/pycocotools/coco.pyi @@ -19,7 +19,7 @@ class COCO: imgs: dict[int, _Image] imgToAnns: dict[int, list[_Annotation]] catToImgs: dict[int, list[int]] - def __init__(self, annotation_file: str | Path = ...) -> None: ... + def __init__(self, annotation_file: str | Path | None = ...) -> None: ... def createIndex(self) -> None: ... def info(self) -> None: ... def getAnnIds( From 99a28bd55b8e25acc30954cdbeb326149b615ad9 Mon Sep 17 00:00:00 2001 From: Hoel Bagard Date: Mon, 7 Nov 2022 13:21:34 +0900 Subject: [PATCH 22/32] Moved the private types to __init__ and the files they are used. --- stubs/pycocotools/pycocotools/__init__.pyi | 9 ++- stubs/pycocotools/pycocotools/coco.pyi | 48 ++++++++++++- stubs/pycocotools/pycocotools/coco_types.pyi | 72 -------------------- stubs/pycocotools/pycocotools/cocoeval.pyi | 20 +++++- stubs/pycocotools/pycocotools/mask.pyi | 2 +- 5 files changed, 70 insertions(+), 81 deletions(-) delete mode 100644 stubs/pycocotools/pycocotools/coco_types.pyi diff --git a/stubs/pycocotools/pycocotools/__init__.pyi b/stubs/pycocotools/pycocotools/__init__.pyi index c33223ae09b0..f8b7a404eceb 100644 --- a/stubs/pycocotools/pycocotools/__init__.pyi +++ b/stubs/pycocotools/pycocotools/__init__.pyi @@ -1,3 +1,6 @@ -from .coco import * -from .cocoeval import * -from .mask import * +from typing_extensions import TypedDict + +# Unused in this module, but imported in multiple submodules. +class _EncodedRLE(TypedDict): # noqa: Y049 + size: list[int] + counts: str | bytes diff --git a/stubs/pycocotools/pycocotools/coco.pyi b/stubs/pycocotools/pycocotools/coco.pyi index db5894a6a311..a645e29330c3 100644 --- a/stubs/pycocotools/pycocotools/coco.pyi +++ b/stubs/pycocotools/pycocotools/coco.pyi @@ -1,9 +1,9 @@ from _typeshed import Incomplete, Self from pathlib import Path -from typing import overload -from typing_extensions import Literal, TypeAlias +from typing import overload, Generic, TypeVar +from typing_extensions import Literal, TypeAlias, TypedDict -from .coco_types import _RLE, _Annotation, _AnnotationG, _Category, _Dataset, _EncodedRLE, _Image, _TPolygonSegmentation +from . import _EncodedRLE # TODO: Use numpy types when #5768 is resolved. # import numpy as np @@ -12,6 +12,48 @@ from .coco_types import _RLE, _Annotation, _AnnotationG, _Category, _Dataset, _E PYTHON_VERSION: Incomplete _NDArray: TypeAlias = Incomplete +class _Image(TypedDict): + id: int + width: int + height: int + file_name: str + +_TPolygonSegmentation: TypeAlias = list[list[float]] + +class _RLE(TypedDict): + size: list[int] + counts: list[int] + +class _Annotation(TypedDict): + id: int + image_id: int + category_id: int + segmentation: _TPolygonSegmentation | _RLE | _EncodedRLE + area: float + bbox: list[float] + iscrowd: int # Either 1 or 0 + +_TSeg = TypeVar("_TSeg", _TPolygonSegmentation, _RLE, _EncodedRLE) + +class _AnnotationG(TypedDict, Generic[_TSeg]): + id: int + image_id: int + category_id: int + segmentation: _TSeg + area: float + bbox: list[float] + iscrowd: int # Either 1 or 0 + +class _Category(TypedDict): + id: int + name: str + supercategory: str + +class _Dataset(TypedDict): + images: list[_Image] + annotations: list[_Annotation] + categories: list[_Category] + class COCO: anns: dict[int, _Annotation] dataset: _Dataset diff --git a/stubs/pycocotools/pycocotools/coco_types.pyi b/stubs/pycocotools/pycocotools/coco_types.pyi deleted file mode 100644 index de97b724326d..000000000000 --- a/stubs/pycocotools/pycocotools/coco_types.pyi +++ /dev/null @@ -1,72 +0,0 @@ -from _typeshed import Incomplete -from typing import Generic, TypeVar -from typing_extensions import TypeAlias, TypedDict - -# TODO: Use numpy types when #5768 is resolved. -# import numpy as np -# import numpy.typing as npt - -_NDArray: TypeAlias = Incomplete - -class _Image(TypedDict): - id: int - width: int - height: int - file_name: str - -_TPolygonSegmentation: TypeAlias = list[list[float]] - -class _RLE(TypedDict): - size: list[int] - counts: list[int] - -class _EncodedRLE(TypedDict): - size: list[int] - counts: str | bytes - -class _Annotation(TypedDict): - id: int - image_id: int - category_id: int - segmentation: _TPolygonSegmentation | _RLE | _EncodedRLE - area: float - bbox: list[float] - iscrowd: int # Either 1 or 0 - -_TSeg = TypeVar("_TSeg", _TPolygonSegmentation, _RLE, _EncodedRLE) - -class _AnnotationG(TypedDict, Generic[_TSeg]): - id: int - image_id: int - category_id: int - segmentation: _TSeg - area: float - bbox: list[float] - iscrowd: int # Either 1 or 0 - -class _Category(TypedDict): - id: int - name: str - supercategory: str - -class _EvaluationResult(TypedDict): - image_id: int - category_id: int - aRng: list[int] - maxDet: int - dtIds: list[int] - gtIds: list[int] - dtMatches: _NDArray - # dtMatches: npt.NDArray[np.float64] - gtMatches: _NDArray - # gtMatches: npt.NDArray[np.float64] - dtScores: list[float] - gtIgnore: _NDArray - # gtIgnore: npt.NDArray[np.float64] - dtIgnore: _NDArray - # dtIgnore: npt.NDArray[np.float64] - -class _Dataset(TypedDict): - images: list[_Image] - annotations: list[_Annotation] - categories: list[_Category] diff --git a/stubs/pycocotools/pycocotools/cocoeval.pyi b/stubs/pycocotools/pycocotools/cocoeval.pyi index 11c38dff7f89..d9845c6cb712 100644 --- a/stubs/pycocotools/pycocotools/cocoeval.pyi +++ b/stubs/pycocotools/pycocotools/cocoeval.pyi @@ -1,8 +1,7 @@ from _typeshed import Incomplete -from typing_extensions import Literal, TypeAlias +from typing_extensions import Literal, TypeAlias, TypedDict from .coco import COCO -from .coco_types import _EvaluationResult # TODO: Use numpy types when #5768 is resolved. # import numpy as np @@ -11,6 +10,23 @@ from .coco_types import _EvaluationResult _NDArray: TypeAlias = Incomplete _TIOU: TypeAlias = Literal["segm", "bbox", "keypoints"] +class _EvaluationResult(TypedDict): + image_id: int + category_id: int + aRng: list[int] + maxDet: int + dtIds: list[int] + gtIds: list[int] + dtMatches: _NDArray + # dtMatches: npt.NDArray[np.float64] + gtMatches: _NDArray + # gtMatches: npt.NDArray[np.float64] + dtScores: list[float] + gtIgnore: _NDArray + # gtIgnore: npt.NDArray[np.float64] + dtIgnore: _NDArray + # dtIgnore: npt.NDArray[np.float64] + class COCOeval: cocoGt: COCO cocoDt: COCO diff --git a/stubs/pycocotools/pycocotools/mask.pyi b/stubs/pycocotools/pycocotools/mask.pyi index 585837c22db9..07d30d6624b9 100644 --- a/stubs/pycocotools/pycocotools/mask.pyi +++ b/stubs/pycocotools/pycocotools/mask.pyi @@ -2,7 +2,7 @@ from _typeshed import Incomplete from typing import Any, overload from typing_extensions import TypeAlias -from .coco_types import _EncodedRLE +from . import _EncodedRLE # TODO: Use numpy types when #5768 is resolved. # import numpy as np From a686ab93b7a46f19c31d3a7561fc5abcf8316ba1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 7 Nov 2022 04:23:01 +0000 Subject: [PATCH 23/32] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/pycocotools/pycocotools/coco.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/pycocotools/pycocotools/coco.pyi b/stubs/pycocotools/pycocotools/coco.pyi index a645e29330c3..fb461ec236de 100644 --- a/stubs/pycocotools/pycocotools/coco.pyi +++ b/stubs/pycocotools/pycocotools/coco.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete, Self from pathlib import Path -from typing import overload, Generic, TypeVar +from typing import Generic, TypeVar, overload from typing_extensions import Literal, TypeAlias, TypedDict from . import _EncodedRLE From 3f668c3a5cd1dd16a5b5b6165a54af568513bde0 Mon Sep 17 00:00:00 2001 From: Hoel Bagard Date: Wed, 16 Nov 2022 12:30:11 +0900 Subject: [PATCH 24/32] Removed comment. --- stubs/pycocotools/pycocotools/coco.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/pycocotools/pycocotools/coco.pyi b/stubs/pycocotools/pycocotools/coco.pyi index fb461ec236de..e262ab0ba114 100644 --- a/stubs/pycocotools/pycocotools/coco.pyi +++ b/stubs/pycocotools/pycocotools/coco.pyi @@ -31,7 +31,7 @@ class _Annotation(TypedDict): segmentation: _TPolygonSegmentation | _RLE | _EncodedRLE area: float bbox: list[float] - iscrowd: int # Either 1 or 0 + iscrowd: int _TSeg = TypeVar("_TSeg", _TPolygonSegmentation, _RLE, _EncodedRLE) @@ -42,7 +42,7 @@ class _AnnotationG(TypedDict, Generic[_TSeg]): segmentation: _TSeg area: float bbox: list[float] - iscrowd: int # Either 1 or 0 + iscrowd: int class _Category(TypedDict): id: int From 34b09cd643e1454d5422286e9df300c8d4a2e210 Mon Sep 17 00:00:00 2001 From: Hoel Bagard Date: Mon, 28 Nov 2022 21:29:33 +0900 Subject: [PATCH 25/32] Updated imports. --- stubs/pycocotools/pycocotools/coco.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stubs/pycocotools/pycocotools/coco.pyi b/stubs/pycocotools/pycocotools/coco.pyi index e262ab0ba114..f033df15ff99 100644 --- a/stubs/pycocotools/pycocotools/coco.pyi +++ b/stubs/pycocotools/pycocotools/coco.pyi @@ -1,4 +1,5 @@ -from _typeshed import Incomplete, Self +from _typeshed import Incomplete +from collections.abc import Collection, Sequence from pathlib import Path from typing import Generic, TypeVar, overload from typing_extensions import Literal, TypeAlias, TypedDict From 74726024f30954c826f88a667db317cef22b2359 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ho=C3=ABl=20Bagard?= <34478245+hoel-bagard@users.noreply.github.com> Date: Mon, 28 Nov 2022 21:30:36 +0900 Subject: [PATCH 26/32] Replace list by Collection/Sequence. Co-authored-by: Alex Waygood --- stubs/pycocotools/pycocotools/coco.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/pycocotools/pycocotools/coco.pyi b/stubs/pycocotools/pycocotools/coco.pyi index f033df15ff99..e74417e24d39 100644 --- a/stubs/pycocotools/pycocotools/coco.pyi +++ b/stubs/pycocotools/pycocotools/coco.pyi @@ -66,7 +66,7 @@ class COCO: def createIndex(self) -> None: ... def info(self) -> None: ... def getAnnIds( - self, imgIds: list[int] | int = ..., catIds: list[int] | int = ..., areaRng: list[float] = ..., iscrowd: bool | None = ... + self, imgIds: Collection[int] | int = ..., catIds: Collection[int] | int = ..., areaRng: Sequence[float] = ..., iscrowd: bool | None = ... ) -> list[int]: ... def getCatIds( self, catNms: list[str] | str = ..., supNms: list[str] | str = ..., catIds: list[int] | int = ... From 6e5bb732d414a70c6ef62b151cbbf71dc9f6cd2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ho=C3=ABl=20Bagard?= <34478245+hoel-bagard@users.noreply.github.com> Date: Mon, 28 Nov 2022 21:30:45 +0900 Subject: [PATCH 27/32] Replace list by Collection/Sequence. Co-authored-by: Alex Waygood --- stubs/pycocotools/pycocotools/coco.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/pycocotools/pycocotools/coco.pyi b/stubs/pycocotools/pycocotools/coco.pyi index e74417e24d39..78bdab9a19cd 100644 --- a/stubs/pycocotools/pycocotools/coco.pyi +++ b/stubs/pycocotools/pycocotools/coco.pyi @@ -69,7 +69,7 @@ class COCO: self, imgIds: Collection[int] | int = ..., catIds: Collection[int] | int = ..., areaRng: Sequence[float] = ..., iscrowd: bool | None = ... ) -> list[int]: ... def getCatIds( - self, catNms: list[str] | str = ..., supNms: list[str] | str = ..., catIds: list[int] | int = ... + self, catNms: Collection[str] | str = ..., supNms: Collection[str] | str = ..., catIds: Collection[int] | int = ... ) -> list[int]: ... def getImgIds(self, imgIds: list[int] | int = ..., catIds: list[int] | int = ...) -> list[int]: ... def loadAnns(self, ids: list[int] | int = ...) -> list[_Annotation]: ... From 885781743984be18f646a0aa85515c2573041bcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ho=C3=ABl=20Bagard?= <34478245+hoel-bagard@users.noreply.github.com> Date: Mon, 28 Nov 2022 21:30:54 +0900 Subject: [PATCH 28/32] Replace list by Collection/Sequence. Co-authored-by: Alex Waygood --- stubs/pycocotools/pycocotools/coco.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/pycocotools/pycocotools/coco.pyi b/stubs/pycocotools/pycocotools/coco.pyi index 78bdab9a19cd..2841490b8f6a 100644 --- a/stubs/pycocotools/pycocotools/coco.pyi +++ b/stubs/pycocotools/pycocotools/coco.pyi @@ -75,7 +75,7 @@ class COCO: def loadAnns(self, ids: list[int] | int = ...) -> list[_Annotation]: ... def loadCats(self, ids: list[int] | int = ...) -> list[_Category]: ... def loadImgs(self, ids: list[int] | int = ...) -> list[_Image]: ... - def showAnns(self, anns: list[_Annotation], draw_bbox: bool = ...) -> None: ... + def showAnns(self, anns: Sequence[_Annotation], draw_bbox: bool = ...) -> None: ... def loadRes(self: Self, resFile: str) -> Self: ... def download(self, tarDir: str | None = ..., imgIds: list[int] = ...) -> Literal[-1] | None: ... def loadNumpyAnnotations(self, data: _NDArray) -> list[_Annotation]: ... From d9a3b8e495a2955cece8d22c443b1b43b3598eca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ho=C3=ABl=20Bagard?= <34478245+hoel-bagard@users.noreply.github.com> Date: Mon, 28 Nov 2022 21:31:01 +0900 Subject: [PATCH 29/32] Replace list by Collection/Sequence. Co-authored-by: Alex Waygood --- stubs/pycocotools/pycocotools/coco.pyi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stubs/pycocotools/pycocotools/coco.pyi b/stubs/pycocotools/pycocotools/coco.pyi index 2841490b8f6a..d10c0dffcd8b 100644 --- a/stubs/pycocotools/pycocotools/coco.pyi +++ b/stubs/pycocotools/pycocotools/coco.pyi @@ -71,10 +71,10 @@ class COCO: def getCatIds( self, catNms: Collection[str] | str = ..., supNms: Collection[str] | str = ..., catIds: Collection[int] | int = ... ) -> list[int]: ... - def getImgIds(self, imgIds: list[int] | int = ..., catIds: list[int] | int = ...) -> list[int]: ... - def loadAnns(self, ids: list[int] | int = ...) -> list[_Annotation]: ... - def loadCats(self, ids: list[int] | int = ...) -> list[_Category]: ... - def loadImgs(self, ids: list[int] | int = ...) -> list[_Image]: ... + def getImgIds(self, imgIds: Collection[int] | int = ..., catIds: list[int] | int = ...) -> list[int]: ... + def loadAnns(self, ids: Collection[int] | int = ...) -> list[_Annotation]: ... + def loadCats(self, ids: Collection[int] | int = ...) -> list[_Category]: ... + def loadImgs(self, ids: Collection[int] | int = ...) -> list[_Image]: ... def showAnns(self, anns: Sequence[_Annotation], draw_bbox: bool = ...) -> None: ... def loadRes(self: Self, resFile: str) -> Self: ... def download(self, tarDir: str | None = ..., imgIds: list[int] = ...) -> Literal[-1] | None: ... From f7a13bfb37c8e16ff13ea18dd110bbc442403f26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ho=C3=ABl=20Bagard?= <34478245+hoel-bagard@users.noreply.github.com> Date: Mon, 28 Nov 2022 21:31:20 +0900 Subject: [PATCH 30/32] Replace list by Sequence. Co-authored-by: Alex Waygood --- stubs/pycocotools/pycocotools/coco.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/pycocotools/pycocotools/coco.pyi b/stubs/pycocotools/pycocotools/coco.pyi index d10c0dffcd8b..c125621072d7 100644 --- a/stubs/pycocotools/pycocotools/coco.pyi +++ b/stubs/pycocotools/pycocotools/coco.pyi @@ -77,7 +77,7 @@ class COCO: def loadImgs(self, ids: Collection[int] | int = ...) -> list[_Image]: ... def showAnns(self, anns: Sequence[_Annotation], draw_bbox: bool = ...) -> None: ... def loadRes(self: Self, resFile: str) -> Self: ... - def download(self, tarDir: str | None = ..., imgIds: list[int] = ...) -> Literal[-1] | None: ... + def download(self, tarDir: str | None = ..., imgIds: Collection[int] = ...) -> Literal[-1] | None: ... def loadNumpyAnnotations(self, data: _NDArray) -> list[_Annotation]: ... # def loadNumpyAnnotations(self, data: npt.NDArray[np.float64]) -> list[_Annotation]: ... @overload From 4d29cf0035099fe4c112d9be467982b47ef4f0bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ho=C3=ABl=20Bagard?= <34478245+hoel-bagard@users.noreply.github.com> Date: Mon, 28 Nov 2022 21:31:40 +0900 Subject: [PATCH 31/32] Replace Self type by COCO, Co-authored-by: Alex Waygood --- stubs/pycocotools/pycocotools/coco.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/pycocotools/pycocotools/coco.pyi b/stubs/pycocotools/pycocotools/coco.pyi index c125621072d7..9e6824a1eafe 100644 --- a/stubs/pycocotools/pycocotools/coco.pyi +++ b/stubs/pycocotools/pycocotools/coco.pyi @@ -76,7 +76,7 @@ class COCO: def loadCats(self, ids: Collection[int] | int = ...) -> list[_Category]: ... def loadImgs(self, ids: Collection[int] | int = ...) -> list[_Image]: ... def showAnns(self, anns: Sequence[_Annotation], draw_bbox: bool = ...) -> None: ... - def loadRes(self: Self, resFile: str) -> Self: ... + def loadRes(self, resFile: str) -> COCO: ... def download(self, tarDir: str | None = ..., imgIds: Collection[int] = ...) -> Literal[-1] | None: ... def loadNumpyAnnotations(self, data: _NDArray) -> list[_Annotation]: ... # def loadNumpyAnnotations(self, data: npt.NDArray[np.float64]) -> list[_Annotation]: ... From 3f28dcb0734d2c255c0e9c76d10b3c5ca010cf22 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 28 Nov 2022 12:31:48 +0000 Subject: [PATCH 32/32] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/pycocotools/pycocotools/coco.pyi | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stubs/pycocotools/pycocotools/coco.pyi b/stubs/pycocotools/pycocotools/coco.pyi index 9e6824a1eafe..1cb93c63f2e9 100644 --- a/stubs/pycocotools/pycocotools/coco.pyi +++ b/stubs/pycocotools/pycocotools/coco.pyi @@ -66,7 +66,11 @@ class COCO: def createIndex(self) -> None: ... def info(self) -> None: ... def getAnnIds( - self, imgIds: Collection[int] | int = ..., catIds: Collection[int] | int = ..., areaRng: Sequence[float] = ..., iscrowd: bool | None = ... + self, + imgIds: Collection[int] | int = ..., + catIds: Collection[int] | int = ..., + areaRng: Sequence[float] = ..., + iscrowd: bool | None = ..., ) -> list[int]: ... def getCatIds( self, catNms: Collection[str] | str = ..., supNms: Collection[str] | str = ..., catIds: Collection[int] | int = ...