Skip to content

Commit

Permalink
[Fix] Fix pre-commit-hook for python3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
HAOCHENYE committed Nov 1, 2024
1 parent c46684c commit c7ba61a
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
- name: Set up Python 3.10.15
uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: '3.10.15'
- name: Install pre-commit hook
run: |
pip install pre-commit
Expand Down
11 changes: 6 additions & 5 deletions .pre-commit-config-zh-cn.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
exclude: ^tests/data/
repos:
- repo: https://gitee.com/openmmlab/mirrors-flake8
rev: 5.0.4
- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
hooks:
- id: flake8
- repo: https://gitee.com/openmmlab/mirrors-isort
Expand All @@ -13,7 +13,7 @@ repos:
hooks:
- id: yapf
- repo: https://gitee.com/openmmlab/mirrors-pre-commit-hooks
rev: v4.3.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: check-yaml
Expand Down Expand Up @@ -53,15 +53,16 @@ repos:
hooks:
- id: check-copyright
args: ["mmcv", "tests", "--excludes", "mmcv/ops"]
- repo: https://gitee.com/openmmlab/mirrors-mypy
rev: v0.812
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.2.0
hooks:
- id: mypy
exclude: |-
(?x)(
^test
| ^docs
)
additional_dependencies: ["types-setuptools", "types-requests"]
# - repo: local
# hooks:
# - id: clang-format
Expand Down
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -54,14 +54,15 @@ 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: |-
(?x)(
^test
| ^docs
)
additional_dependencies: ["types-setuptools", "types-requests"]
# - repo: local
# hooks:
# - id: clang-format
Expand Down
2 changes: 1 addition & 1 deletion mmcv/ops/iou3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion mmcv/transforms/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion mmcv/transforms/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion mmcv/visualization/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit c7ba61a

Please sign in to comment.