From 6be501b34de6fb8c1172d95c2d592c40b0336ac5 Mon Sep 17 00:00:00 2001 From: Takafumi Iju Date: Tue, 28 Dec 2021 16:24:35 +0900 Subject: [PATCH 1/6] Add code formatter --- .pre-commit-config.yaml | 14 ++++++++++++++ contributing/README.md | 19 ++++++++++++++++++- contributing/requirements.txt | 3 ++- 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..b42009f --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,14 @@ +- repo: https://github.com/psf/black + rev: 20.8b1 + hooks: + - id: black +- repo: https://gitlab.com/pycqa/flake8 + rev: 3.8.4 + hooks: + - id: flake8 + args: ['--extend-ignore=E203', '--max-line-length=88'] +- repo: https://github.com/pycqa/isort + rev: 5.6.4 + hooks: + - id: isort + args: ['--profile black'] diff --git a/contributing/README.md b/contributing/README.md index 1d9d69d..069bdc3 100644 --- a/contributing/README.md +++ b/contributing/README.md @@ -18,5 +18,22 @@ $ pip install -r contributing/requirements.txt ### Run Formatter and Linter ```bash -make all +$ make all ``` + +### Enable pre-commit hook + +```bash +$ pre-commit install +``` + +Basically, `pre-commit` will only run on the changed files. +But if you execute the bellow command, you can run on all of files. + +```bash +$ pre-commit run --all-files +``` + +#### How to enable on your IDE + +* [VS code](https://marketplace.visualstudio.com/items?itemName=MarkLarah.pre-commit-vscode) diff --git a/contributing/requirements.txt b/contributing/requirements.txt index b3b14f7..e892e8f 100644 --- a/contributing/requirements.txt +++ b/contributing/requirements.txt @@ -1,3 +1,4 @@ black==20.8b1 flake8==3.8.4 -isort==5.6.4 \ No newline at end of file +isort==5.6.4 +pre-commit==2.16.0 From f7d024b5e1f9458f1c731c25345ade975a175141 Mon Sep 17 00:00:00 2001 From: Takafumi Iju Date: Tue, 28 Dec 2021 20:11:46 +0900 Subject: [PATCH 2/6] Modify yaml file. --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b42009f..e0c4415 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,4 @@ +repos: - repo: https://github.com/psf/black rev: 20.8b1 hooks: From 35dc88e6a28872a6f99269d57366bbd076a52ede Mon Sep 17 00:00:00 2001 From: Takafumi Iju Date: Tue, 28 Dec 2021 20:31:20 +0900 Subject: [PATCH 3/6] Fixed option of isort. --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e0c4415..11f31ac 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,4 +12,4 @@ repos: rev: 5.6.4 hooks: - id: isort - args: ['--profile black'] + args: ['--profile', 'black'] From 0d166c5f35facf443366f0f419e310f85e8f9ab3 Mon Sep 17 00:00:00 2001 From: Takafumi Iju Date: Wed, 29 Dec 2021 08:02:48 +0900 Subject: [PATCH 4/6] Modify README.md --- contributing/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contributing/README.md b/contributing/README.md index 069bdc3..6d1ecc4 100644 --- a/contributing/README.md +++ b/contributing/README.md @@ -28,7 +28,7 @@ $ pre-commit install ``` Basically, `pre-commit` will only run on the changed files. -But if you execute the bellow command, you can run on all of files. +But if you execute the bellow command, you can run on all files. ```bash $ pre-commit run --all-files @@ -36,4 +36,7 @@ $ pre-commit run --all-files #### How to enable on your IDE +`pre-commit` will only run when you commit the file by manual. +So, you should do additional settings if you want to commit the file using IDE. + * [VS code](https://marketplace.visualstudio.com/items?itemName=MarkLarah.pre-commit-vscode) From 4160c3779914210070125897a1149b5f14bec6ba Mon Sep 17 00:00:00 2001 From: Takafumi Iju Date: Thu, 30 Dec 2021 21:38:56 +0900 Subject: [PATCH 5/6] Add types --- .pre-commit-config.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 11f31ac..6312378 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,13 +3,19 @@ repos: rev: 20.8b1 hooks: - id: black + files: '^.*\.py' + types: [file] - repo: https://gitlab.com/pycqa/flake8 rev: 3.8.4 hooks: - id: flake8 args: ['--extend-ignore=E203', '--max-line-length=88'] + files: '^.*\.py' + types: [file] - repo: https://github.com/pycqa/isort rev: 5.6.4 hooks: - id: isort args: ['--profile', 'black'] + files: '^.*\.py' + types: [file] From b3bce7c3a28b14e37052f3bf04d668fb6caf23d3 Mon Sep 17 00:00:00 2001 From: Takafumi Iju Date: Thu, 30 Dec 2021 22:24:40 +0900 Subject: [PATCH 6/6] Remove inappropriate explanation --- contributing/README.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/contributing/README.md b/contributing/README.md index 6d1ecc4..0832187 100644 --- a/contributing/README.md +++ b/contributing/README.md @@ -33,10 +33,3 @@ But if you execute the bellow command, you can run on all files. ```bash $ pre-commit run --all-files ``` - -#### How to enable on your IDE - -`pre-commit` will only run when you commit the file by manual. -So, you should do additional settings if you want to commit the file using IDE. - -* [VS code](https://marketplace.visualstudio.com/items?itemName=MarkLarah.pre-commit-vscode)