From ba4a496562dff7ab71fc6813f647ef78f1e43693 Mon Sep 17 00:00:00 2001 From: JiayuXu <84259897+JiayuXu0@users.noreply.github.com> Date: Sat, 8 Oct 2022 19:41:49 +0800 Subject: [PATCH] Upgrade pre commit hooks (#129) * Fix the version conflict in CircleCI * Update pre-commit config and add zh-cn version. * Add codespell ignore list. * Add codespell ignore list. * Add check copyright config. --- .pre-commit-config-zh-cn.yaml | 60 +++++++++++++++++++ .pre-commit-config.yaml | 13 ++-- setup.cfg | 2 +- tests/test_datasets/__init__.py | 1 + .../test_datasets/test_transforms/__init__.py | 1 + tests/test_engine/__init__.py | 1 + tests/test_engine/test_optimizers/__init__.py | 1 + tests/test_models/__init__.py | 1 + tests/test_models/test_backbone/__init__.py | 1 + .../test_data_preprocessor/__init__.py | 1 + .../test_models/test_dense_heads/__init__.py | 1 + tests/test_models/test_layers/__init__.py | 1 + tests/test_models/test_necks/__init__.py | 1 + .../test_task_modules/test_coders/__init__.py | 1 + tests/test_models/test_utils/__init__.py | 1 + tests/test_models/test_utils/test_misc.py | 1 + tests/test_utils/test_setup_env.py | 1 + 17 files changed, 81 insertions(+), 8 deletions(-) create mode 100644 .pre-commit-config-zh-cn.yaml diff --git a/.pre-commit-config-zh-cn.yaml b/.pre-commit-config-zh-cn.yaml new file mode 100644 index 00000000..9b98d009 --- /dev/null +++ b/.pre-commit-config-zh-cn.yaml @@ -0,0 +1,60 @@ +exclude: ^tests/data/ +repos: + - repo: https://gitee.com/openmmlab/mirrors-flake8 + rev: 5.0.4 + hooks: + - id: flake8 + - repo: https://gitee.com/openmmlab/mirrors-isort + rev: 5.10.1 + hooks: + - id: isort + - repo: https://gitee.com/openmmlab/mirrors-yapf + rev: v0.32.0 + hooks: + - id: yapf + - repo: https://gitee.com/openmmlab/mirrors-pre-commit-hooks + rev: v4.3.0 + hooks: + - id: trailing-whitespace + - id: check-yaml + - id: end-of-file-fixer + - id: requirements-txt-fixer + - id: double-quote-string-fixer + - id: check-merge-conflict + - id: fix-encoding-pragma + args: ["--remove"] + - id: mixed-line-ending + args: ["--fix=lf"] + - repo: https://gitee.com/openmmlab/mirrors-mdformat + rev: 0.7.9 + hooks: + - id: mdformat + args: ["--number"] + additional_dependencies: + - mdformat-openmmlab + - mdformat_frontmatter + - linkify-it-py + - repo: https://gitee.com/openmmlab/mirrors-codespell + rev: v2.2.1 + hooks: + - id: codespell + - repo: https://gitee.com/openmmlab/mirrors-docformatter + rev: v1.3.1 + hooks: + - id: docformatter + args: ["--in-place", "--wrap-descriptions", "79"] + - repo: https://gitee.com/openmmlab/mirrors-pyupgrade + rev: v3.0.0 + hooks: + - id: pyupgrade + args: ["--py36-plus"] + - repo: https://github.com/open-mmlab/pre-commit-hooks + rev: v0.2.0 + hooks: + - id: check-copyright + args: ["mmyolo", "tests"] +# - repo: https://gitee.com/openmmlab/mirrors-mypy +# rev: v0.812 +# hooks: +# - id: mypy +# exclude: "docs" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fb3f86bc..7ccdff38 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: 3.8.3 + rev: 5.0.4 hooks: - id: flake8 - repo: https://github.com/PyCQA/isort @@ -9,11 +9,11 @@ repos: hooks: - id: isort - repo: https://github.com/pre-commit/mirrors-yapf - rev: v0.30.0 + rev: v0.32.0 hooks: - id: yapf - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.1.0 + rev: v4.3.0 hooks: - id: trailing-whitespace - id: check-yaml @@ -35,7 +35,7 @@ repos: - mdformat_frontmatter - linkify-it-py - repo: https://github.com/codespell-project/codespell - rev: v2.1.0 + rev: v2.2.1 hooks: - id: codespell - repo: https://github.com/myint/docformatter @@ -44,7 +44,7 @@ repos: - id: docformatter args: ["--in-place", "--wrap-descriptions", "79"] - repo: https://github.com/asottile/pyupgrade - rev: v2.32.1 + rev: v3.0.0 hooks: - id: pyupgrade args: ["--py36-plus"] @@ -52,8 +52,7 @@ repos: rev: v0.2.0 hooks: - id: check-copyright -# args: ["mmyolo", "tests"] - args: ["mmyolo"] + args: ["mmyolo", "tests"] # - repo: https://github.com/pre-commit/mirrors-mypy # rev: v0.812 # hooks: diff --git a/setup.cfg b/setup.cfg index 6a054f01..d44cba0e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -18,4 +18,4 @@ SPLIT_BEFORE_EXPRESSION_AFTER_OPENING_PAREN = true [codespell] skip = *.ipynb quiet-level = 3 -ignore-words-list = patten,nd,ty,mot,hist,formating,winn,gool,datas,wan,confids,TOOD,tood,ba +ignore-words-list = patten,nd,ty,mot,hist,formating,winn,gool,datas,wan,confids,TOOD,tood,ba,warmup,elease diff --git a/tests/test_datasets/__init__.py b/tests/test_datasets/__init__.py index e69de29b..ef101fec 100644 --- a/tests/test_datasets/__init__.py +++ b/tests/test_datasets/__init__.py @@ -0,0 +1 @@ +# Copyright (c) OpenMMLab. All rights reserved. diff --git a/tests/test_datasets/test_transforms/__init__.py b/tests/test_datasets/test_transforms/__init__.py index e69de29b..ef101fec 100644 --- a/tests/test_datasets/test_transforms/__init__.py +++ b/tests/test_datasets/test_transforms/__init__.py @@ -0,0 +1 @@ +# Copyright (c) OpenMMLab. All rights reserved. diff --git a/tests/test_engine/__init__.py b/tests/test_engine/__init__.py index e69de29b..ef101fec 100644 --- a/tests/test_engine/__init__.py +++ b/tests/test_engine/__init__.py @@ -0,0 +1 @@ +# Copyright (c) OpenMMLab. All rights reserved. diff --git a/tests/test_engine/test_optimizers/__init__.py b/tests/test_engine/test_optimizers/__init__.py index e69de29b..ef101fec 100644 --- a/tests/test_engine/test_optimizers/__init__.py +++ b/tests/test_engine/test_optimizers/__init__.py @@ -0,0 +1 @@ +# Copyright (c) OpenMMLab. All rights reserved. diff --git a/tests/test_models/__init__.py b/tests/test_models/__init__.py index e69de29b..ef101fec 100644 --- a/tests/test_models/__init__.py +++ b/tests/test_models/__init__.py @@ -0,0 +1 @@ +# Copyright (c) OpenMMLab. All rights reserved. diff --git a/tests/test_models/test_backbone/__init__.py b/tests/test_models/test_backbone/__init__.py index e69de29b..ef101fec 100644 --- a/tests/test_models/test_backbone/__init__.py +++ b/tests/test_models/test_backbone/__init__.py @@ -0,0 +1 @@ +# Copyright (c) OpenMMLab. All rights reserved. diff --git a/tests/test_models/test_data_preprocessor/__init__.py b/tests/test_models/test_data_preprocessor/__init__.py index e69de29b..ef101fec 100644 --- a/tests/test_models/test_data_preprocessor/__init__.py +++ b/tests/test_models/test_data_preprocessor/__init__.py @@ -0,0 +1 @@ +# Copyright (c) OpenMMLab. All rights reserved. diff --git a/tests/test_models/test_dense_heads/__init__.py b/tests/test_models/test_dense_heads/__init__.py index e69de29b..ef101fec 100644 --- a/tests/test_models/test_dense_heads/__init__.py +++ b/tests/test_models/test_dense_heads/__init__.py @@ -0,0 +1 @@ +# Copyright (c) OpenMMLab. All rights reserved. diff --git a/tests/test_models/test_layers/__init__.py b/tests/test_models/test_layers/__init__.py index e69de29b..ef101fec 100644 --- a/tests/test_models/test_layers/__init__.py +++ b/tests/test_models/test_layers/__init__.py @@ -0,0 +1 @@ +# Copyright (c) OpenMMLab. All rights reserved. diff --git a/tests/test_models/test_necks/__init__.py b/tests/test_models/test_necks/__init__.py index e69de29b..ef101fec 100644 --- a/tests/test_models/test_necks/__init__.py +++ b/tests/test_models/test_necks/__init__.py @@ -0,0 +1 @@ +# Copyright (c) OpenMMLab. All rights reserved. diff --git a/tests/test_models/test_task_modules/test_coders/__init__.py b/tests/test_models/test_task_modules/test_coders/__init__.py index e69de29b..ef101fec 100644 --- a/tests/test_models/test_task_modules/test_coders/__init__.py +++ b/tests/test_models/test_task_modules/test_coders/__init__.py @@ -0,0 +1 @@ +# Copyright (c) OpenMMLab. All rights reserved. diff --git a/tests/test_models/test_utils/__init__.py b/tests/test_models/test_utils/__init__.py index e69de29b..ef101fec 100644 --- a/tests/test_models/test_utils/__init__.py +++ b/tests/test_models/test_utils/__init__.py @@ -0,0 +1 @@ +# Copyright (c) OpenMMLab. All rights reserved. diff --git a/tests/test_models/test_utils/test_misc.py b/tests/test_models/test_utils/test_misc.py index e69de29b..ef101fec 100644 --- a/tests/test_models/test_utils/test_misc.py +++ b/tests/test_models/test_utils/test_misc.py @@ -0,0 +1 @@ +# Copyright (c) OpenMMLab. All rights reserved. diff --git a/tests/test_utils/test_setup_env.py b/tests/test_utils/test_setup_env.py index 76c53dd4..e6bd6890 100644 --- a/tests/test_utils/test_setup_env.py +++ b/tests/test_utils/test_setup_env.py @@ -1,3 +1,4 @@ +# Copyright (c) OpenMMLab. All rights reserved. import datetime import sys from unittest import TestCase