From 6abba8a1735385116fe686807a670b91aa23a2bc Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Fri, 19 Mar 2021 08:00:28 +0100 Subject: [PATCH 01/16] .pre-commit-config.yaml: mypy directories that pass --- .pre-commit-config.yaml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a3288e1c5eef..7ef5ffa73151 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.2.0 + # rev: v3.2.0 hooks: - id: check-executables-have-shebangs - id: check-yaml @@ -13,32 +13,32 @@ repos: )$ - id: requirements-txt-fixer - repo: https://github.com/psf/black - rev: stable + # rev: stable hooks: - id: black - repo: https://github.com/PyCQA/isort - rev: 5.5.3 + # rev: 5.7.0 hooks: - id: isort args: - --profile=black - repo: https://gitlab.com/pycqa/flake8 - rev: 3.8.3 + # rev: 3.9.0 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 +# FIXME: fix mypy errors in other directories and add them here + - repo: https://github.com/pre-commit/mirrors-mypy + # rev: v0.812 + hooks: + - id: mypy + args: + - --ignore-missing-imports arithmetic_analysis backtracking bit_manipulation blockchain boolean_algebra cellular_automata computer_vision digital_image_processing fuzzy_logic genetic_algorithm geodesy knapsack networking_flow scheduling sorts - repo: https://github.com/codespell-project/codespell - rev: v1.17.1 + # rev: v1.17.1 hooks: - id: codespell args: From 83d603d1ab757e373386e27208114ba9b8fc1c35 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Fri, 19 Mar 2021 07:00:53 +0000 Subject: [PATCH 02/16] updating DIRECTORY.md --- DIRECTORY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/DIRECTORY.md b/DIRECTORY.md index dfb673dea829..136825e41976 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -472,6 +472,7 @@ * [Runge Kutta](https://github.com/TheAlgorithms/Python/blob/master/maths/runge_kutta.py) * [Segmented Sieve](https://github.com/TheAlgorithms/Python/blob/master/maths/segmented_sieve.py) * Series + * [Arithmetic Mean](https://github.com/TheAlgorithms/Python/blob/master/maths/series/arithmetic_mean.py) * [Geometric Mean](https://github.com/TheAlgorithms/Python/blob/master/maths/series/geometric_mean.py) * [Geometric Series](https://github.com/TheAlgorithms/Python/blob/master/maths/series/geometric_series.py) * [Harmonic Series](https://github.com/TheAlgorithms/Python/blob/master/maths/series/harmonic_series.py) From ccd7de63d650c13e20ee208de5e6552289f3969c Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Fri, 19 Mar 2021 08:04:22 +0100 Subject: [PATCH 03/16] Update .pre-commit-config.yaml --- .pre-commit-config.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7ef5ffa73151..fb6d73cc9632 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - # rev: v3.2.0 + rev: v3.4.0 hooks: - id: check-executables-have-shebangs - id: check-yaml @@ -13,17 +13,17 @@ repos: )$ - id: requirements-txt-fixer - repo: https://github.com/psf/black - # rev: stable + rev: stable hooks: - id: black - repo: https://github.com/PyCQA/isort - # rev: 5.7.0 + rev: 5.7.0 hooks: - id: isort args: - --profile=black - repo: https://gitlab.com/pycqa/flake8 - # rev: 3.9.0 + rev: 3.9.0 hooks: - id: flake8 args: @@ -32,13 +32,13 @@ repos: - --max-line-length=88 # FIXME: fix mypy errors in other directories and add them here - repo: https://github.com/pre-commit/mirrors-mypy - # rev: v0.812 + rev: v0.812 hooks: - id: mypy args: - --ignore-missing-imports arithmetic_analysis backtracking bit_manipulation blockchain boolean_algebra cellular_automata computer_vision digital_image_processing fuzzy_logic genetic_algorithm geodesy knapsack networking_flow scheduling sorts - repo: https://github.com/codespell-project/codespell - # rev: v1.17.1 + rev: v2.0.0 hooks: - id: codespell args: From 70cc689fe6aee6ace69ead68c6142a90482a797e Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Fri, 19 Mar 2021 08:09:38 +0100 Subject: [PATCH 04/16] Fix typo discovered by codespell --- maths/polynomial_evaluation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maths/polynomial_evaluation.py b/maths/polynomial_evaluation.py index e929a2d02972..68ff97ddd25d 100644 --- a/maths/polynomial_evaluation.py +++ b/maths/polynomial_evaluation.py @@ -5,7 +5,7 @@ def evaluate_poly(poly: Sequence[float], x: float) -> float: """Evaluate a polynomial f(x) at specified point x and return the value. Arguments: - poly -- the coeffiecients of a polynomial as an iterable in order of + poly -- the coefficients of a polynomial as an iterable in order of ascending degree x -- the point at which to evaluate the polynomial @@ -26,7 +26,7 @@ def horner(poly: Sequence[float], x: float) -> float: https://en.wikipedia.org/wiki/Horner's_method Arguments: - poly -- the coeffiecients of a polynomial as an iterable in order of + poly -- the coefficients of a polynomial as an iterable in order of ascending degree x -- the point at which to evaluate the polynomial From e7dba80da3064076c1eaa45cc18b971319d39acd Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Fri, 19 Mar 2021 08:10:30 +0100 Subject: [PATCH 05/16] Fix typo discovered by codespell --- searches/hill_climbing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/searches/hill_climbing.py b/searches/hill_climbing.py index 70622ebefb4e..bb24e781a6c1 100644 --- a/searches/hill_climbing.py +++ b/searches/hill_climbing.py @@ -60,7 +60,7 @@ def get_neighbors(self): def __hash__(self): """ - hash the string represetation of the current search state. + hash the string representation of the current search state. """ return hash(str(self)) From 16912872016e4c0c5ceb8b6af730804769faca82 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Fri, 19 Mar 2021 08:12:35 +0100 Subject: [PATCH 06/16] Fix typo discovered by codespell --- machine_learning/k_nearest_neighbours.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machine_learning/k_nearest_neighbours.py b/machine_learning/k_nearest_neighbours.py index e90ea09a58c1..2a90cfe5987a 100644 --- a/machine_learning/k_nearest_neighbours.py +++ b/machine_learning/k_nearest_neighbours.py @@ -32,7 +32,7 @@ def classifier(train_data, train_target, classes, point, k=5): :train_data: Set of points that are classified into two or more classes :train_target: List of classes in the order of train_data points :classes: Labels of the classes - :point: The data point that needs to be classifed + :point: The data point that needs to be classified >>> X_train = [[0, 0], [1, 0], [0, 1], [0.5, 0.5], [3, 3], [2, 3], [3, 2]] >>> y_train = [0, 0, 0, 0, 1, 1, 1] From 95031cf2c316704fde0fb84203056cf9981fc6a0 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Fri, 19 Mar 2021 08:14:32 +0100 Subject: [PATCH 07/16] Separate mypy args --- .pre-commit-config.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fb6d73cc9632..458b3de06013 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,13 +36,14 @@ repos: hooks: - id: mypy args: - - --ignore-missing-imports arithmetic_analysis backtracking bit_manipulation blockchain boolean_algebra cellular_automata computer_vision digital_image_processing fuzzy_logic genetic_algorithm geodesy knapsack networking_flow scheduling sorts + - --ignore-missing-imports + - arithmetic_analysis backtracking bit_manipulation blockchain boolean_algebra cellular_automata computer_vision digital_image_processing fuzzy_logic genetic_algorithm geodesy knapsack networking_flow scheduling sorts - repo: https://github.com/codespell-project/codespell rev: v2.0.0 hooks: - id: codespell args: - - --ignore-words-list=ans,fo,followings,hist,iff,mater,secant,som,tim + - --ignore-words-list=ans,crate,fo,followings,hist,iff,mater,secant,som,tim - --skip="./.*,./other/dictionary.txt,./other/words,./project_euler/problem_022/p022_names.txt" - --quiet-level=2 exclude: | From a819ee9c6f06cdcb5d6d93f8490b801daaafd614 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Fri, 19 Mar 2021 08:19:40 +0100 Subject: [PATCH 08/16] pin https://github.com/psf/black/releases --- .pre-commit-config.yaml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 458b3de06013..3a9e948adb11 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: )$ - id: requirements-txt-fixer - repo: https://github.com/psf/black - rev: stable + rev: v20.8b1 hooks: - id: black - repo: https://github.com/PyCQA/isort @@ -37,7 +37,20 @@ repos: - id: mypy args: - --ignore-missing-imports - - arithmetic_analysis backtracking bit_manipulation blockchain boolean_algebra cellular_automata computer_vision digital_image_processing fuzzy_logic genetic_algorithm geodesy knapsack networking_flow scheduling sorts + - arithmetic_analysis + - backtracking + - bit_manipulation + - blockchain + - boolean_algebra + - cellular_automata + - computer_vision + - digital_image_processing + - fuzzy_logic + - genetic_algorithm + - geodesy + - knapsack + - networking_flow + - scheduling sorts - repo: https://github.com/codespell-project/codespell rev: v2.0.0 hooks: From a7175e93f4f5447eae153c876ec396bd21f1fc17 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Fri, 19 Mar 2021 08:21:20 +0100 Subject: [PATCH 09/16] black rev: 20.8b1 --- .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 3a9e948adb11..7cda5e04cdea 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: )$ - id: requirements-txt-fixer - repo: https://github.com/psf/black - rev: v20.8b1 + rev: 20.8b1 hooks: - id: black - repo: https://github.com/PyCQA/isort From 9cf97f8f0028b582783cc079e4e552b051b5d32c Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Fri, 19 Mar 2021 08:23:47 +0100 Subject: [PATCH 10/16] Update .pre-commit-config.yaml --- .pre-commit-config.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7cda5e04cdea..e5bba040510c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -50,7 +50,8 @@ repos: - geodesy - knapsack - networking_flow - - scheduling sorts + - scheduling + - sorts - repo: https://github.com/codespell-project/codespell rev: v2.0.0 hooks: From 391ab89db26ed8e0ab7dceaf8289dfa7a918375c Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Fri, 19 Mar 2021 08:26:29 +0100 Subject: [PATCH 11/16] Remove mypy digital_image_processing --- .pre-commit-config.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e5bba040510c..51dce9dad30c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -44,7 +44,6 @@ repos: - boolean_algebra - cellular_automata - computer_vision - - digital_image_processing - fuzzy_logic - genetic_algorithm - geodesy From bbab7bf1eb7d356215a7eb30c0aef441e503c8da Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Fri, 19 Mar 2021 08:30:54 +0100 Subject: [PATCH 12/16] knapsack # missing __init__.py --- .pre-commit-config.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 51dce9dad30c..b430b533f620 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -44,10 +44,11 @@ repos: - boolean_algebra - cellular_automata - computer_vision + # - digital_image_processing # missing __init__.py - fuzzy_logic - genetic_algorithm - geodesy - - knapsack + # - knapsack # missing __init__.py - networking_flow - scheduling - sorts From 71353ee0f1a141ab35dfe7dd51ae4763c4fac9ec Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Fri, 19 Mar 2021 08:34:51 +0100 Subject: [PATCH 13/16] computer_vision # missing __init__.py --- .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 b430b533f620..12c5a8cafa5f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,7 +43,7 @@ repos: - blockchain - boolean_algebra - cellular_automata - - computer_vision + # - computer_vision # missing __init__.py # - digital_image_processing # missing __init__.py - fuzzy_logic - genetic_algorithm From 37bc3cd3dd499c819b89510d7dc0a57270ee61b1 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Fri, 19 Mar 2021 08:42:00 +0100 Subject: [PATCH 14/16] mypy --namespace-packages --- .pre-commit-config.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 12c5a8cafa5f..7a6f04d2a3ba 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -37,18 +37,19 @@ repos: - id: mypy args: - --ignore-missing-imports + - --namespace-packages - arithmetic_analysis - backtracking - bit_manipulation - blockchain - boolean_algebra - cellular_automata - # - computer_vision # missing __init__.py - # - digital_image_processing # missing __init__.py + - computer_vision + - digital_image_processing - fuzzy_logic - genetic_algorithm - geodesy - # - knapsack # missing __init__.py + - knapsack - networking_flow - scheduling - sorts From 0937ce207e689a96c9bbccb1887c31c96c833218 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Fri, 19 Mar 2021 10:08:54 +0100 Subject: [PATCH 15/16] # - sorts # missing __init__.py --- .pre-commit-config.yaml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7a6f04d2a3ba..97499a7e3f9e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -37,22 +37,21 @@ repos: - id: mypy args: - --ignore-missing-imports - - --namespace-packages - arithmetic_analysis - backtracking - bit_manipulation - blockchain - boolean_algebra - cellular_automata - - computer_vision - - digital_image_processing + # - computer_vision # missing __init__.py + # - digital_image_processing # missing __init__.py - fuzzy_logic - genetic_algorithm - geodesy - - knapsack + # - knapsack # missing __init__.py - networking_flow - scheduling - - sorts + # - sorts # missing __init__.py - repo: https://github.com/codespell-project/codespell rev: v2.0.0 hooks: From a2d48df32dc0af790db3c4b6154aa7ea58077b53 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Fri, 19 Mar 2021 10:43:33 +0100 Subject: [PATCH 16/16] Revert changes moved to #4273 --- .pre-commit-config.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 97499a7e3f9e..bd062a887bd3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.4.0 + rev: v3.2.0 hooks: - id: check-executables-have-shebangs - id: check-yaml @@ -13,17 +13,17 @@ repos: )$ - id: requirements-txt-fixer - repo: https://github.com/psf/black - rev: 20.8b1 + rev: stable hooks: - id: black - repo: https://github.com/PyCQA/isort - rev: 5.7.0 + rev: 5.5.3 hooks: - id: isort args: - --profile=black - repo: https://gitlab.com/pycqa/flake8 - rev: 3.9.0 + rev: 3.8.3 hooks: - id: flake8 args: @@ -39,7 +39,7 @@ repos: - --ignore-missing-imports - arithmetic_analysis - backtracking - - bit_manipulation + # - bit_manipulation # missing __init__.py - blockchain - boolean_algebra - cellular_automata @@ -53,11 +53,11 @@ repos: - scheduling # - sorts # missing __init__.py - repo: https://github.com/codespell-project/codespell - rev: v2.0.0 + rev: v1.17.1 hooks: - id: codespell args: - - --ignore-words-list=ans,crate,fo,followings,hist,iff,mater,secant,som,tim + - --ignore-words-list=ans,fo,followings,hist,iff,mater,secant,som,tim - --skip="./.*,./other/dictionary.txt,./other/words,./project_euler/problem_022/p022_names.txt" - --quiet-level=2 exclude: |