From fe9083352fb6611111740bc5cc511039d0d84763 Mon Sep 17 00:00:00 2001 From: Roman Yurchak Date: Sat, 18 Apr 2020 12:46:54 +0200 Subject: [PATCH 1/7] Add pre-comit configuration --- .pre-commit-config.yaml | 24 ++++++++++++++++++++++++ doc/developers/contributing.rst | 10 ++++++++-- 2 files changed, 32 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 0000000000000..1e308c48a14c3 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,24 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace +- repo: https://gitlab.com/pycqa/flake8 + rev: 3.7.8 + hooks: + - id: flake8 + types: [file, python] + # only check for unused impors for now, as long as + # the code is not fully PEP8 compatible + args: [--select=F401] +- repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.730 + hooks: + - id: mypy + args: + - --ignore-missing-imports + - --follow-imports + - skip + files: sklearn/ diff --git a/doc/developers/contributing.rst b/doc/developers/contributing.rst index 99c59ec3392c6..d58a1cfba8fee 100644 --- a/doc/developers/contributing.rst +++ b/doc/developers/contributing.rst @@ -248,7 +248,13 @@ modifying code and submitting a PR: and start making changes. Always use a feature branch. It's good practice to never work on the ``master`` branch! -9. Develop the feature on your feature branch on your computer, using Git to +9. Install `pre-commit `_ to run code style + checks before each commit:: + + $ pip install pre-commit + $ pre-commit install + +10. Develop the feature on your feature branch on your computer, using Git to do the version control. When you're done editing, add changed files using ``git add`` and then ``git commit``:: @@ -260,7 +266,7 @@ modifying code and submitting a PR: $ git push -u origin my_feature -10. Follow `these +11. Follow `these `_ instructions to create a pull request from your fork. This will send an email to the committers. You may want to consider sending an email to the From 399e54436210259113a318fe07e80d0a23c1a08b Mon Sep 17 00:00:00 2001 From: Roman Yurchak Date: Sat, 18 Apr 2020 13:23:56 +0200 Subject: [PATCH 2/7] Fix doc syntax --- doc/developers/contributing.rst | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/developers/contributing.rst b/doc/developers/contributing.rst index d58a1cfba8fee..45f9b917a05ba 100644 --- a/doc/developers/contributing.rst +++ b/doc/developers/contributing.rst @@ -255,14 +255,14 @@ modifying code and submitting a PR: $ pre-commit install 10. Develop the feature on your feature branch on your computer, using Git to - do the version control. When you're done editing, add changed files using - ``git add`` and then ``git commit``:: - - $ git add modified_files - $ git commit - - to record your changes in Git, then push the changes to your GitHub - account with:: + do the version control. When you're done editing, add changed files using + ``git add`` and then ``git commit``:: + + $ git add modified_files + $ git commit + + to record your changes in Git, then push the changes to your GitHub + account with:: $ git push -u origin my_feature From 08fb033247603013a98f237512ac27737e580160 Mon Sep 17 00:00:00 2001 From: Roman Yurchak Date: Sat, 18 Apr 2020 16:00:13 +0200 Subject: [PATCH 3/7] Update doc/developers/contributing.rst Co-Authored-By: Nicolas Hug --- doc/developers/contributing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/developers/contributing.rst b/doc/developers/contributing.rst index 45f9b917a05ba..e59c704197a22 100644 --- a/doc/developers/contributing.rst +++ b/doc/developers/contributing.rst @@ -248,7 +248,7 @@ modifying code and submitting a PR: and start making changes. Always use a feature branch. It's good practice to never work on the ``master`` branch! -9. Install `pre-commit `_ to run code style +9. (**Optional**) Install `pre-commit `_ to run code style checks before each commit:: $ pip install pre-commit From 739adc0df879c754bf6674253360150490f46303 Mon Sep 17 00:00:00 2001 From: Roman Yurchak Date: Sat, 18 Apr 2020 16:00:19 +0200 Subject: [PATCH 4/7] Update .pre-commit-config.yaml Co-Authored-By: Nicolas Hug --- .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 1e308c48a14c3..69289c81ea8cf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: hooks: - id: flake8 types: [file, python] - # only check for unused impors for now, as long as + # only check for unused imports for now, as long as # the code is not fully PEP8 compatible args: [--select=F401] - repo: https://github.com/pre-commit/mirrors-mypy From 777a11d53465918b6b8dab3b2c2e11161b2423a3 Mon Sep 17 00:00:00 2001 From: Roman Yurchak Date: Sat, 18 Apr 2020 16:04:50 +0200 Subject: [PATCH 5/7] Fix line lenght --- doc/developers/contributing.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/developers/contributing.rst b/doc/developers/contributing.rst index e59c704197a22..d0bb93546cfa0 100644 --- a/doc/developers/contributing.rst +++ b/doc/developers/contributing.rst @@ -248,8 +248,8 @@ modifying code and submitting a PR: and start making changes. Always use a feature branch. It's good practice to never work on the ``master`` branch! -9. (**Optional**) Install `pre-commit `_ to run code style - checks before each commit:: +9. (**Optional**) Install `pre-commit `_ to + run code style checks before each commit:: $ pip install pre-commit $ pre-commit install From 0caf4b706a1b50b36ea957fe4418eca40d183958 Mon Sep 17 00:00:00 2001 From: Roman Yurchak Date: Sat, 18 Apr 2020 16:35:35 +0200 Subject: [PATCH 6/7] Remove --follow-imports skip option in mypy --- .pre-commit-config.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 69289c81ea8cf..aa8df3c3cbc87 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,6 +19,4 @@ repos: - id: mypy args: - --ignore-missing-imports - - --follow-imports - - skip files: sklearn/ From a457efcca0f28e2939eb9e9fa5d4ef6787ff8fae Mon Sep 17 00:00:00 2001 From: Roman Yurchak Date: Sun, 19 Apr 2020 16:43:05 +0200 Subject: [PATCH 7/7] Added mention of git commit -n --- doc/developers/contributing.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/developers/contributing.rst b/doc/developers/contributing.rst index d0bb93546cfa0..33ab3fcecb887 100644 --- a/doc/developers/contributing.rst +++ b/doc/developers/contributing.rst @@ -254,6 +254,9 @@ modifying code and submitting a PR: $ pip install pre-commit $ pre-commit install + pre-commit checks can be disabled for a particular commit with + `git commit -n`. + 10. Develop the feature on your feature branch on your computer, using Git to do the version control. When you're done editing, add changed files using ``git add`` and then ``git commit``::