Unverified Commit 3fa58518 authored by Kai Chen's avatar Kai Chen Committed by GitHub
Browse files

Update pre-commit hook config (#200)

* update pre-commit hook config

* update the contributing guide
parent ac78bdc2
exclude: ^tests/data/
repos:
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.9
hooks:
- id: flake8
- repo: https://github.com/asottile/seed-isort-config
rev: v1.9.3
rev: v2.1.0
hooks:
- id: seed-isort-config
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.21
- repo: https://github.com/timothycrosley/isort
rev: 4.3.21
hooks:
- id: isort
- repo: https://github.com/pre-commit/mirrors-yapf
......@@ -13,10 +17,12 @@ repos:
hooks:
- id: yapf
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
rev: v2.5.0
hooks:
- id: flake8
- id: trailing-whitespace
- id: check-yaml
- id: end-of-file-fixer
- id: requirements-txt-fixer
- id: double-quote-string-fixer
- id: fix-encoding-pragma
args: ["--remove"]
# Contributing to mmcv
# Contributing to MMCV
All kinds of contributions are welcome, including but not limited to the following.
......@@ -7,7 +7,7 @@ All kinds of contributions are welcome, including but not limited to the followi
## Workflow
1. fork and pull the latest mmcv
1. fork and pull the latest MMCV
2. checkout a new branch (do not use master branch for PRs)
3. commit your changes
4. create a PR
......@@ -24,7 +24,25 @@ We use the following tools for linting and formatting:
- [yapf](https://github.com/google/yapf): formatter
- [isort](https://github.com/timothycrosley/isort): sort imports
Style configurations of yapf and isort can be found in [.style.yapf](.style.yapf) and [.isort.cfg](.isort.cfg).
Style configurations of yapf and isort can be found in [setup.cfg](./setup.cfg).
We use [pre-commit hook](https://pre-commit.com/) that checks and formats for `flake8`, `yapf`, `isort`, `trailing whitespaces`,
fixes `end-of-files`, sorts `requirments.txt` automatically on every commit.
The config for a pre-commit hook is stored in [.pre-commit-config](./.pre-commit-config.yaml).
After you clone the repository, you will need to install initialize pre-commit hook.
```
pip install -U pre-commit
```
From the repository folder
```
pre-commit install
```
After this on every commit check code linters and formatter will be enforced.
>Before you create a PR, make sure that your code lints and is formatted by yapf.
......
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
......
......@@ -9,7 +9,7 @@ from .weight_init import constant_init, kaiming_init
def conv3x3(in_planes, out_planes, stride=1, dilation=1):
"3x3 convolution with padding"
"""3x3 convolution with padding"""
return nn.Conv2d(
in_planes,
out_planes,
......
......@@ -8,7 +8,7 @@ from .weight_init import constant_init, kaiming_init, normal_init
def conv3x3(in_planes, out_planes, dilation=1):
"3x3 convolution with padding"
"""3x3 convolution with padding"""
return nn.Conv2d(
in_planes,
out_planes,
......
......@@ -21,7 +21,7 @@ def collate(batch, samples_per_gpu=1):
"""
if not isinstance(batch, collections.Sequence):
raise TypeError("{} is not supported.".format(batch.dtype))
raise TypeError('{} is not supported.'.format(batch.dtype))
if isinstance(batch[0], DataContainer):
assert len(batch) % samples_per_gpu == 0
......
......@@ -2,7 +2,7 @@
from .checkpoint import (_load_checkpoint, load_checkpoint, load_state_dict,
save_checkpoint, weights_to_cpu)
from .dist_utils import get_dist_info, init_dist, master_only
from .hooks import (CheckpointHook, ClosureHook, DistSamplerSeedHook, HOOKS,
from .hooks import (HOOKS, CheckpointHook, ClosureHook, DistSamplerSeedHook,
Hook, IterTimerHook, LoggerHook, LrUpdaterHook,
OptimizerHook, PaviLoggerHook, TensorboardLoggerHook,
TextLoggerHook, WandbLoggerHook)
......
......@@ -53,7 +53,7 @@ def test_wandb_hook():
model=model,
batch_processor=lambda model, x, **kwargs: {
'log_vars': {
"accuracy": 0.98
'accuracy': 0.98
},
'num_samples': 5
})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment