From db02da85f00960c018eb6672a57475bbcf1c5219 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Wed, 30 Sep 2020 09:12:10 +0530 Subject: [PATCH 1/5] Add pre-commit basic config file --- .pre-commit-config.yaml | 55 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000000..68b1ddef7e0f --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,55 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: check-executables-have-shebangs + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - id: requirements-txt-fixer + - repo: https://github.com/psf/black + rev: 20.8b1 + hooks: + - id: black + - repo: https://github.com/PyCQA/isort + rev: 5.5.3 + hooks: + - id: isort + args: + - --profile black + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.8.3 + hooks: + - id: flake8 + args: + - --ignore=E203,W503 + - --max-complexity=25 + - --max-line-length=88 +# FIXME: fix mypy errors and then uncomment this +# - repo: https://github.com/pre-commit/mirrors-mypy +# rev: v0.782 +# hooks: +# - id: mypy +# args: +# - --ignore-missing-imports + - repo: https://github.com/codespell-project/codespell + rev: v1.17.1 + hooks: + - id: codespell + args: + - --ignore-words-list=ans,fo,followings,hist,iff,secant,som,tim + - --skip="./.*,./other/dictionary.txt,./other/words,./project_euler/problem_22/p022_names.txt" + - --quiet-level=2 + exclude: | + (?x)^( + other/dictionary.txt| + other/words| + project_euler/problem_22/p022_names.txt + )$ + - repo: local + hooks: + - id: validate-filenames + name: Validate filenames + entry: ./scripts/validate_filenames.py + language: script + pass_filenames: false From a3e1dafbf19b6f3b5a4ff8d00ac7b23b8f1b41a8 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Wed, 30 Sep 2020 10:32:05 +0530 Subject: [PATCH 2/5] Add pre-commit to requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index b070ffdf611d..cb38123dc026 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,6 +10,7 @@ numpy opencv-python pandas pillow +pre-commit pytest pytest-cov requests From dd18484e00e53cd12988a5438ab99d9d5b3ed2a9 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Wed, 30 Sep 2020 10:44:47 +0530 Subject: [PATCH 3/5] Small tweaks and use stable for black --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 68b1ddef7e0f..ec6c9907de9d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,7 @@ repos: - id: trailing-whitespace - id: requirements-txt-fixer - repo: https://github.com/psf/black - rev: 20.8b1 + rev: stable hooks: - id: black - repo: https://github.com/PyCQA/isort @@ -42,8 +42,8 @@ repos: - --quiet-level=2 exclude: | (?x)^( - other/dictionary.txt| - other/words| + other/dictionary.txt | + other/words | project_euler/problem_22/p022_names.txt )$ - repo: local From fdbb8aacb5b2b7b7a5cebec90e38fef2f9ceaa9c Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Wed, 30 Sep 2020 11:23:53 +0530 Subject: [PATCH 4/5] Fix isort section in pre-commit-config file --- .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 ec6c9907de9d..4f24c7cc7f27 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,7 @@ repos: hooks: - id: isort args: - - --profile black + - --profile=black - repo: https://gitlab.com/pycqa/flake8 rev: 3.8.3 hooks: From da8990de5f3fce2cfa716181175aeb59044cf583 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Wed, 30 Sep 2020 12:21:36 +0530 Subject: [PATCH 5/5] Fix errors and EOF only for Python files --- .pre-commit-config.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4f24c7cc7f27..2fbb9cb9bdb2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,12 @@ repos: - id: check-executables-have-shebangs - id: check-yaml - id: end-of-file-fixer + types: [python] - id: trailing-whitespace + exclude: | + (?x)^( + data_structures/heap/binomial_heap.py + )$ - id: requirements-txt-fixer - repo: https://github.com/psf/black rev: stable