From 0ed36cfc9038f046af96f1aa1d250eddff1d980c Mon Sep 17 00:00:00 2001 From: HAOCHENYE <21724054@zju.edu.cn> Date: Sat, 2 Nov 2024 00:48:24 +0800 Subject: [PATCH] [Fix] Fix pre-commit-hook for python3.12 --- .pre-commit-config.yaml | 8 ++++---- mmcv/ops/iou3d.py | 2 +- mmcv/transforms/processing.py | 2 +- mmcv/transforms/wrappers.py | 2 +- mmcv/visualization/image.py | 2 +- setup.cfg | 3 +++ 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 76ded556f9..ccc6b3960c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ exclude: ^tests/data/ repos: - repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 + rev: 7.1.1 hooks: - id: flake8 - repo: https://github.com/PyCQA/isort @@ -13,7 +13,7 @@ repos: hooks: - id: yapf - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v5.0.0 hooks: - id: trailing-whitespace - id: check-yaml @@ -54,7 +54,7 @@ repos: - id: check-copyright args: ["mmcv", "tests", "--excludes", "mmcv/ops"] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.812 + rev: v1.2.0 hooks: - id: mypy exclude: |- @@ -62,7 +62,7 @@ repos: ^test | ^docs ) - # - repo: local + additional_dependencies: ["types-setuptools", "types-requests"] # hooks: # - id: clang-format # name: clang-format diff --git a/mmcv/ops/iou3d.py b/mmcv/ops/iou3d.py index 94e2057ad2..dd47993917 100755 --- a/mmcv/ops/iou3d.py +++ b/mmcv/ops/iou3d.py @@ -42,7 +42,7 @@ def boxes_iou3d(boxes_a: Tensor, boxes_b: Tensor) -> Tensor: Returns: torch.Tensor: 3D IoU result with shape (M, N). """ - assert boxes_a.shape[1] == boxes_b.shape[1] == 7,\ + assert boxes_a.shape[1] == boxes_b.shape[1] == 7, \ 'Input boxes shape should be (N, 7)' boxes_a_height_max = (boxes_a[:, 2] + boxes_a[:, 5] / 2).view(-1, 1) diff --git a/mmcv/transforms/processing.py b/mmcv/transforms/processing.py index 8b65b112b6..d490745a65 100644 --- a/mmcv/transforms/processing.py +++ b/mmcv/transforms/processing.py @@ -1457,7 +1457,7 @@ class RandomResize(BaseTransform): def __init__( self, scale: Union[Tuple[int, int], Sequence[Tuple[int, int]]], - ratio_range: Tuple[float, float] = None, + ratio_range: Optional[Tuple[float, float]] = None, resize_type: str = 'Resize', **resize_kwargs, ) -> None: diff --git a/mmcv/transforms/wrappers.py b/mmcv/transforms/wrappers.py index 27e07d6335..ed20449d1e 100644 --- a/mmcv/transforms/wrappers.py +++ b/mmcv/transforms/wrappers.py @@ -177,7 +177,7 @@ class KeyMapper(BaseTransform): """ def __init__(self, - transforms: Union[Transform, List[Transform]] = None, + transforms: Union[Transform, List[Transform], None] = None, mapping: Optional[Dict] = None, remapping: Optional[Dict] = None, auto_remap: Optional[bool] = None, diff --git a/mmcv/visualization/image.py b/mmcv/visualization/image.py index e7ac4c1817..0c4624aabd 100644 --- a/mmcv/visualization/image.py +++ b/mmcv/visualization/image.py @@ -91,7 +91,7 @@ def imshow_bboxes(img: Union[str, np.ndarray], def imshow_det_bboxes(img: Union[str, np.ndarray], bboxes: np.ndarray, labels: np.ndarray, - class_names: List[str] = None, + class_names: Optional[List[str]] = None, score_thr: float = 0, bbox_color: ColorType = 'green', text_color: ColorType = 'green', diff --git a/setup.cfg b/setup.cfg index dc8d3768ef..6be591f137 100644 --- a/setup.cfg +++ b/setup.cfg @@ -24,3 +24,6 @@ default_section = THIRDPARTY [codespell] quiet-level = 3 ignore-words-list = inout,hist,ba,ro,inh + +[mypy] +ignore_missing_imports = true