Skip to content

Commit bfa0796

Browse files
Merge branch 'TheAlgorithms:master' into fix-mypy-errs-5
2 parents 731624d + 3f9150c commit bfa0796

File tree

123 files changed

+1102
-427
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+1102
-427
lines changed

Diff for: .flake8

-10
This file was deleted.

Diff for: .github/ISSUE_TEMPLATE/other.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Other
2+
description: Use this for any other issues. PLEASE do not create blank issues
3+
labels: ["awaiting triage"]
4+
body:
5+
- type: textarea
6+
id: issuedescription
7+
attributes:
8+
label: What would you like to share?
9+
description: Provide a clear and concise explanation of your issue.
10+
validations:
11+
required: true
12+
13+
- type: textarea
14+
id: extrainfo
15+
attributes:
16+
label: Additional information
17+
description: Is there anything else we should know about this issue?
18+
validations:
19+
required: false

Diff for: .github/workflows/ruff.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# https://beta.ruff.rs
2+
name: ruff
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
jobs:
11+
ruff:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- run: pip install --user ruff
16+
- run: ruff --format=github .

Diff for: .pre-commit-config.yaml

+21-54
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ repos:
33
rev: v4.4.0
44
hooks:
55
- id: check-executables-have-shebangs
6+
- id: check-toml
67
- id: check-yaml
78
- id: end-of-file-fixer
89
types: [python]
@@ -14,81 +15,47 @@ repos:
1415
hooks:
1516
- id: auto-walrus
1617

18+
- repo: https://github.com/charliermarsh/ruff-pre-commit
19+
rev: v0.0.257
20+
hooks:
21+
- id: ruff
22+
1723
- repo: https://github.com/psf/black
1824
rev: 23.1.0
1925
hooks:
2026
- id: black
2127

22-
- repo: https://github.com/PyCQA/isort
23-
rev: 5.12.0
28+
- repo: https://github.com/codespell-project/codespell
29+
rev: v2.2.4
2430
hooks:
25-
- id: isort
26-
args:
27-
- --profile=black
31+
- id: codespell
32+
additional_dependencies:
33+
- tomli
2834

2935
- repo: https://github.com/tox-dev/pyproject-fmt
30-
rev: "0.6.0"
36+
rev: "0.9.2"
3137
hooks:
3238
- id: pyproject-fmt
3339

40+
- repo: local
41+
hooks:
42+
- id: validate-filenames
43+
name: Validate filenames
44+
entry: ./scripts/validate_filenames.py
45+
language: script
46+
pass_filenames: false
47+
3448
- repo: https://github.com/abravalheri/validate-pyproject
3549
rev: v0.12.1
3650
hooks:
3751
- id: validate-pyproject
3852

39-
- repo: https://github.com/asottile/pyupgrade
40-
rev: v3.3.1
41-
hooks:
42-
- id: pyupgrade
43-
args:
44-
- --py311-plus
45-
46-
- repo: https://github.com/PyCQA/flake8
47-
rev: 6.0.0
48-
hooks:
49-
- id: flake8 # See .flake8 for args
50-
additional_dependencies: &flake8-plugins
51-
- flake8-bugbear
52-
- flake8-builtins
53-
# - flake8-broken-line
54-
- flake8-comprehensions
55-
- pep8-naming
56-
57-
- repo: https://github.com/asottile/yesqa
58-
rev: v1.4.0
59-
hooks:
60-
- id: yesqa
61-
additional_dependencies:
62-
*flake8-plugins
63-
6453
- repo: https://github.com/pre-commit/mirrors-mypy
65-
rev: v0.991
54+
rev: v1.1.1
6655
hooks:
6756
- id: mypy
6857
args:
6958
- --ignore-missing-imports
7059
- --install-types # See mirrors-mypy README.md
7160
- --non-interactive
7261
additional_dependencies: [types-requests]
73-
74-
- repo: https://github.com/codespell-project/codespell
75-
rev: v2.2.2
76-
hooks:
77-
- id: codespell
78-
args:
79-
- --ignore-words-list=ans,crate,damon,fo,followings,hist,iff,mater,secant,som,sur,tim,zar
80-
exclude: |
81-
(?x)^(
82-
ciphers/prehistoric_men.txt |
83-
strings/dictionary.txt |
84-
strings/words.txt |
85-
project_euler/problem_022/p022_names.txt
86-
)$
87-
88-
- repo: local
89-
hooks:
90-
- id: validate-filenames
91-
name: Validate filenames
92-
entry: ./scripts/validate_filenames.py
93-
language: script
94-
pass_filenames: false

Diff for: CONTRIBUTING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ We want your work to be readable by others; therefore, we encourage you to note
8181
black .
8282
```
8383

84-
- All submissions will need to pass the test `flake8 . --ignore=E203,W503 --max-line-length=88` before they will be accepted so if possible, try this test locally on your Python file(s) before submitting your pull request.
84+
- All submissions will need to pass the test `ruff .` before they will be accepted so if possible, try this test locally on your Python file(s) before submitting your pull request.
8585

8686
```bash
87-
python3 -m pip install flake8 # only required the first time
88-
flake8 . --ignore=E203,W503 --max-line-length=88 --show-source
87+
python3 -m pip install ruff # only required the first time
88+
ruff .
8989
```
9090

9191
- Original code submission require docstrings or comments to describe your work.

Diff for: DIRECTORY.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,14 @@
196196
* [Disjoint Set](data_structures/disjoint_set/disjoint_set.py)
197197
* Hashing
198198
* [Double Hash](data_structures/hashing/double_hash.py)
199+
* [Hash Map](data_structures/hashing/hash_map.py)
199200
* [Hash Table](data_structures/hashing/hash_table.py)
200201
* [Hash Table With Linked List](data_structures/hashing/hash_table_with_linked_list.py)
201202
* Number Theory
202203
* [Prime Numbers](data_structures/hashing/number_theory/prime_numbers.py)
203204
* [Quadratic Probing](data_structures/hashing/quadratic_probing.py)
205+
* Tests
206+
* [Test Hash Map](data_structures/hashing/tests/test_hash_map.py)
204207
* Heap
205208
* [Binomial Heap](data_structures/heap/binomial_heap.py)
206209
* [Heap](data_structures/heap/heap.py)
@@ -334,6 +337,7 @@
334337
## Electronics
335338
* [Builtin Voltage](electronics/builtin_voltage.py)
336339
* [Carrier Concentration](electronics/carrier_concentration.py)
340+
* [Circular Convolution](electronics/circular_convolution.py)
337341
* [Coulombs Law](electronics/coulombs_law.py)
338342
* [Electric Conductivity](electronics/electric_conductivity.py)
339343
* [Electric Power](electronics/electric_power.py)
@@ -918,6 +922,8 @@
918922
* [Sol1](project_euler/problem_080/sol1.py)
919923
* Problem 081
920924
* [Sol1](project_euler/problem_081/sol1.py)
925+
* Problem 082
926+
* [Sol1](project_euler/problem_082/sol1.py)
921927
* Problem 085
922928
* [Sol1](project_euler/problem_085/sol1.py)
923929
* Problem 086
@@ -934,6 +940,8 @@
934940
* [Sol1](project_euler/problem_097/sol1.py)
935941
* Problem 099
936942
* [Sol1](project_euler/problem_099/sol1.py)
943+
* Problem 100
944+
* [Sol1](project_euler/problem_100/sol1.py)
937945
* Problem 101
938946
* [Sol1](project_euler/problem_101/sol1.py)
939947
* Problem 102
@@ -954,6 +962,8 @@
954962
* [Sol1](project_euler/problem_115/sol1.py)
955963
* Problem 116
956964
* [Sol1](project_euler/problem_116/sol1.py)
965+
* Problem 117
966+
* [Sol1](project_euler/problem_117/sol1.py)
957967
* Problem 119
958968
* [Sol1](project_euler/problem_119/sol1.py)
959969
* Problem 120
@@ -966,6 +976,8 @@
966976
* [Sol1](project_euler/problem_125/sol1.py)
967977
* Problem 129
968978
* [Sol1](project_euler/problem_129/sol1.py)
979+
* Problem 131
980+
* [Sol1](project_euler/problem_131/sol1.py)
969981
* Problem 135
970982
* [Sol1](project_euler/problem_135/sol1.py)
971983
* Problem 144
@@ -1163,7 +1175,6 @@
11631175
* [Get Amazon Product Data](web_programming/get_amazon_product_data.py)
11641176
* [Get Imdb Top 250 Movies Csv](web_programming/get_imdb_top_250_movies_csv.py)
11651177
* [Get Imdbtop](web_programming/get_imdbtop.py)
1166-
* [Get Top Billionaires](web_programming/get_top_billionaires.py)
11671178
* [Get Top Hn Posts](web_programming/get_top_hn_posts.py)
11681179
* [Get User Tweets](web_programming/get_user_tweets.py)
11691180
* [Giphy](web_programming/giphy.py)

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<!-- Second row: -->
2323
<br>
2424
<a href="https://github.com/TheAlgorithms/Python/actions">
25-
<img src="https://img.shields.io/github/workflow/status/TheAlgorithms/Python/build?label=CI&logo=github&style=flat-square" height="20" alt="GitHub Workflow Status">
25+
<img src="https://img.shields.io/github/actions/workflow/status/TheAlgorithms/Python/build.yml?branch=master&label=CI&logo=github&style=flat-square" height="20" alt="GitHub Workflow Status">
2626
</a>
2727
<a href="https://github.com/pre-commit/pre-commit">
2828
<img src="https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=flat-square" height="20" alt="pre-commit">

Diff for: arithmetic_analysis/newton_raphson.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from __future__ import annotations
66

77
from decimal import Decimal
8-
from math import * # noqa: F401, F403
8+
from math import * # noqa: F403
99

1010
from sympy import diff
1111

Diff for: arithmetic_analysis/newton_raphson_new.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# Newton's Method - https://en.wikipedia.org/wiki/Newton's_method
99

1010
from sympy import diff, lambdify, symbols
11-
from sympy.functions import * # noqa: F401, F403
11+
from sympy.functions import * # noqa: F403
1212

1313

1414
def newton_raphson(

Diff for: audio_filters/equal_loudness_filter.py.broken.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class EqualLoudnessFilter:
2020
samplerate, use with caution.
2121

2222
Code based on matlab implementation at https://bit.ly/3eqh2HU
23-
(url shortened for flake8)
23+
(url shortened for ruff)
2424

2525
Target curve: https://i.imgur.com/3g2VfaM.png
2626
Yulewalk response: https://i.imgur.com/J9LnJ4C.png

Diff for: audio_filters/iir_filter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def set_coefficients(self, a_coeffs: list[float], b_coeffs: list[float]) -> None
4747
>>> filt.set_coefficients(a_coeffs, b_coeffs)
4848
"""
4949
if len(a_coeffs) < self.order:
50-
a_coeffs = [1.0] + a_coeffs
50+
a_coeffs = [1.0, *a_coeffs]
5151

5252
if len(a_coeffs) != self.order + 1:
5353
raise ValueError(

Diff for: backtracking/n_queens_math.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ def depth_first_search(
129129

130130
# If it is False we call dfs function again and we update the inputs
131131
depth_first_search(
132-
possible_board + [col],
133-
diagonal_right_collisions + [row - col],
134-
diagonal_left_collisions + [row + col],
132+
[*possible_board, col],
133+
[*diagonal_right_collisions, row - col],
134+
[*diagonal_left_collisions, row + col],
135135
boards,
136136
n,
137137
)

Diff for: backtracking/sum_of_subsets.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def create_state_space_tree(
4444
nums,
4545
max_sum,
4646
index + 1,
47-
path + [nums[index]],
47+
[*path, nums[index]],
4848
result,
4949
remaining_nums_sum - nums[index],
5050
)

0 commit comments

Comments
 (0)