Skip to content

Commit 51681d2

Browse files
committed
[Fix] Fix pre-commit-hook for python3.12
1 parent c46684c commit 51681d2

23 files changed

Lines changed: 66 additions & 49 deletions

‎.github/workflows/lint.yml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ jobs:
1111
runs-on: ubuntu-22.04
1212
steps:
1313
- uses: actions/checkout@v2
14-
- name: Set up Python 3.7
14+
- name: Set up Python 3.10.15
1515
uses: actions/setup-python@v2
1616
with:
17-
python-version: 3.7
17+
python-version: '3.10.15'
1818
- name: Install pre-commit hook
1919
run: |
20+
pip install setuptools
2021
pip install pre-commit
2122
pre-commit install
2223
- name: Linting

‎.pre-commit-config-zh-cn.yaml‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
exclude: ^tests/data/
22
repos:
3-
- repo: https://gitee.com/openmmlab/mirrors-flake8
4-
rev: 5.0.4
3+
- repo: https://github.com/pre-commit/pre-commit
4+
rev: v4.0.0
5+
hooks:
6+
- id: validate_manifest
7+
- repo: https://github.com/PyCQA/flake8
8+
rev: 7.1.1
59
hooks:
610
- id: flake8
711
- repo: https://gitee.com/openmmlab/mirrors-isort
@@ -13,7 +17,7 @@ repos:
1317
hooks:
1418
- id: yapf
1519
- repo: https://gitee.com/openmmlab/mirrors-pre-commit-hooks
16-
rev: v4.3.0
20+
rev: v5.0.0
1721
hooks:
1822
- id: trailing-whitespace
1923
- id: check-yaml
@@ -53,15 +57,16 @@ repos:
5357
hooks:
5458
- id: check-copyright
5559
args: ["mmcv", "tests", "--excludes", "mmcv/ops"]
56-
- repo: https://gitee.com/openmmlab/mirrors-mypy
57-
rev: v0.812
60+
- repo: https://github.com/pre-commit/mirrors-mypy
61+
rev: v1.2.0
5862
hooks:
5963
- id: mypy
6064
exclude: |-
6165
(?x)(
6266
^test
6367
| ^docs
6468
)
69+
additional_dependencies: ["types-setuptools", "types-requests"]
6570
# - repo: local
6671
# hooks:
6772
# - id: clang-format

‎.pre-commit-config.yaml‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
exclude: ^tests/data/
22
repos:
3+
- repo: https://github.com/pre-commit/pre-commit
4+
rev: v4.0.0
5+
hooks:
6+
- id: validate_manifest
37
- repo: https://github.com/PyCQA/flake8
4-
rev: 5.0.4
8+
rev: 7.1.1
59
hooks:
610
- id: flake8
711
- repo: https://github.com/PyCQA/isort
@@ -13,7 +17,7 @@ repos:
1317
hooks:
1418
- id: yapf
1519
- repo: https://github.com/pre-commit/pre-commit-hooks
16-
rev: v4.3.0
20+
rev: v5.0.0
1721
hooks:
1822
- id: trailing-whitespace
1923
- id: check-yaml
@@ -39,7 +43,7 @@ repos:
3943
- mdformat_frontmatter
4044
- linkify-it-py
4145
- repo: https://github.com/myint/docformatter
42-
rev: v1.3.1
46+
rev: 06907d0
4347
hooks:
4448
- id: docformatter
4549
args: ["--in-place", "--wrap-descriptions", "79"]
@@ -54,14 +58,15 @@ repos:
5458
- id: check-copyright
5559
args: ["mmcv", "tests", "--excludes", "mmcv/ops"]
5660
- repo: https://github.com/pre-commit/mirrors-mypy
57-
rev: v0.812
61+
rev: v1.2.0
5862
hooks:
5963
- id: mypy
6064
exclude: |-
6165
(?x)(
6266
^test
6367
| ^docs
6468
)
69+
additional_dependencies: ["types-setuptools", "types-requests"]
6570
# - repo: local
6671
# hooks:
6772
# - id: clang-format

‎mmcv/cnn/bricks/drop.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ def drop_path(x: torch.Tensor,
1313
residual blocks).
1414
1515
We follow the implementation
16-
https://github.com/rwightman/pytorch-image-models/blob/a2727c1bf78ba0d7b5727f5f95e37fb7f8866b1f/timm/models/layers/drop.py # noqa: E501
16+
https://github.com/rwightman/pytorch-image-models/blob/a2727c1bf78ba0d7b5727f5f95e37fb7f8866b1f/timm/models/layers/drop.py
17+
# noqa: E501
1718
"""
1819
if drop_prob == 0. or not training:
1920
return x

‎mmcv/cnn/rfsearch/search.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def __init__(self,
7171
self.by_epoch = by_epoch
7272

7373
def init_model(self, model: nn.Module):
74-
"""init model with search ability.
74+
"""Init model with search ability.
7575
7676
Args:
7777
model (nn.Module): pytorch model
@@ -132,7 +132,7 @@ def step(self, model: nn.Module, work_dir: str) -> None:
132132
)
133133

134134
def estimate_and_expand(self, model: nn.Module) -> None:
135-
"""estimate and search for RFConvOp.
135+
"""Estimate and search for RFConvOp.
136136
137137
Args:
138138
model (nn.Module): pytorch model
@@ -146,7 +146,7 @@ def wrap_model(self,
146146
model: nn.Module,
147147
search_op: str = 'Conv2d',
148148
prefix: str = '') -> None:
149-
"""wrap model to support searchable conv op.
149+
"""Wrap model to support searchable conv op.
150150
151151
Args:
152152
model (nn.Module): pytorch model
@@ -187,7 +187,7 @@ def set_model(self,
187187
search_op: str = 'Conv2d',
188188
init_rates: Optional[int] = None,
189189
prefix: str = '') -> None:
190-
"""set model based on config.
190+
"""Set model based on config.
191191
192192
Args:
193193
model (nn.Module): pytorch model

‎mmcv/cnn/rfsearch/utils.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
def write_to_json(config: dict, filename: str):
7-
"""save config to json file.
7+
"""Save config to json file.
88
99
Args:
1010
config (dict): Config to be saved.
@@ -16,7 +16,7 @@ def write_to_json(config: dict, filename: str):
1616

1717

1818
def expand_rates(dilation: tuple, config: dict) -> list:
19-
"""expand dilation rate according to config.
19+
"""Expand dilation rate according to config.
2020
2121
Args:
2222
dilation (int): _description_

‎mmcv/ops/active_rotated_filter.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ class ActiveRotatedFilterFunction(Function):
1616
"""Encoding the orientation information and generating orientation-
1717
sensitive features.
1818
19-
The details are described in the paper `Align Deep Features for Oriented
20-
Object Detection <https://arxiv.org/abs/2008.09397>_`.
21-
"""
19+
The details are described in the paper
20+
`Align Deep Features for Oriented Object Detection <https://arxiv.org/abs/2008.09397>_`.
21+
""" # noqa: E501
2222

2323
@staticmethod
2424
def forward(ctx, input: torch.Tensor,

‎mmcv/ops/cc_attention.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __init__(self, in_channels: int) -> None:
5151
self.in_channels = in_channels
5252

5353
def forward(self, x: torch.Tensor) -> torch.Tensor:
54-
"""forward function of Criss-Cross Attention.
54+
"""Forward function of Criss-Cross Attention.
5555
5656
Args:
5757
x (torch.Tensor): Input feature with the shape of

‎mmcv/ops/chamfer_distance.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ class ChamferDistanceFunction(Function):
1616
"""This is an implementation of the 2D Chamfer Distance.
1717
1818
It has been used in the paper `Oriented RepPoints for Aerial Object
19-
Detection (CVPR 2022) <https://arxiv.org/abs/2105.11111>_`.
19+
Detection (CVPR 2022)
20+
<https://arxiv.org/abs/2105.11111>_`.
2021
"""
2122

2223
@staticmethod

‎mmcv/ops/correlation.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def _output_size(ctx, input1):
116116

117117

118118
class Correlation(nn.Module):
119-
r"""Correlation operator
119+
r"""Correlation operator.
120120
121121
This correlation operator works for optical flow correlation computation.
122122

0 commit comments

Comments
 (0)