Skip to content

Commit 5a4dbd4

Browse files
authored
Merge branch 'master' into master
2 parents d1229d7 + eea1bac commit 5a4dbd4

10 files changed

Lines changed: 52 additions & 12 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
with:
1616
enable-cache: true
1717
cache-dependency-glob: uv.lock
18-
- uses: actions/setup-python@v6
18+
- uses: actions/setup-python@v7
1919
with:
2020
python-version: 3.14
2121
allow-prereleases: true

.github/workflows/directory_writer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
- uses: actions/checkout@v7
1010
with:
1111
fetch-depth: 0
12-
- uses: actions/setup-python@v6
12+
- uses: actions/setup-python@v7
1313
with:
1414
python-version: 3.14
1515
allow-prereleases: true

.github/workflows/project_euler.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
libopenblas-dev
2424
- uses: actions/checkout@v7
2525
- uses: astral-sh/setup-uv@v7
26-
- uses: actions/setup-python@v6
26+
- uses: actions/setup-python@v7
2727
with:
2828
python-version: 3.14
2929
allow-prereleases: true
@@ -41,7 +41,7 @@ jobs:
4141
libopenblas-dev
4242
- uses: actions/checkout@v7
4343
- uses: astral-sh/setup-uv@v7
44-
- uses: actions/setup-python@v6
44+
- uses: actions/setup-python@v7
4545
with:
4646
python-version: 3.14
4747
allow-prereleases: true

.github/workflows/sphinx.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
libopenblas-dev
3535
- uses: actions/checkout@v7
3636
- uses: astral-sh/setup-uv@v7
37-
- uses: actions/setup-python@v6
37+
- uses: actions/setup-python@v7
3838
with:
3939
python-version: 3.14
4040
allow-prereleases: true

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ repos:
1919
- id: auto-walrus
2020

2121
- repo: https://github.com/astral-sh/ruff-pre-commit
22-
rev: v0.15.20
22+
rev: v0.16.1
2323
hooks:
2424
- id: ruff-check
2525
- id: ruff-format

ciphers/a1z26.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,21 @@ def encode(plain: str) -> list[int]:
1313
"""
1414
>>> encode("myname")
1515
[13, 25, 14, 1, 13, 5]
16+
>>> encode("abCd")
17+
Traceback (most recent call last):
18+
...
19+
ValueError: plain must contain only lowercase letters (a-z)
20+
>>> encode("n0w")
21+
Traceback (most recent call last):
22+
...
23+
ValueError: plain must contain only lowercase letters (a-z)
24+
>>> encode("later!")
25+
Traceback (most recent call last):
26+
...
27+
ValueError: plain must contain only lowercase letters (a-z)
1628
"""
29+
if not plain.islower() or not plain.isalpha():
30+
raise ValueError("plain must contain only lowercase letters (a-z)")
1731
return [ord(elem) - 96 for elem in plain]
1832

1933

data_structures/binary_tree/inorder_tree_traversal_2022.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def insert(node: BinaryTreeNode | None, new_value: int) -> BinaryTreeNode | None
4343
return node
4444

4545

46-
def inorder(node: None | BinaryTreeNode) -> list[int]: # if node is None,return
46+
def inorder(node: BinaryTreeNode | None) -> list[int]: # if node is None,return
4747
"""
4848
>>> inorder(make_tree())
4949
[6, 10, 14, 15, 20, 25, 60]

machine_learning/sequential_minimum_optimization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ def test_cancer_data():
451451
print("Hello!\nStart test SVM using the SMO algorithm!")
452452
# 0: download dataset and load into pandas' dataframe
453453
if not os.path.exists(r"cancer_data.csv"):
454-
request = urllib.request.Request( # noqa: S310
454+
request = urllib.request.Request(
455455
CANCER_DATASET_URL,
456456
headers={"User-Agent": "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)"},
457457
)

sorts/bubble_sort.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@
22

33

44
def bubble_sort_iterative(collection: list[Any]) -> list[Any]:
5-
"""Pure implementation of bubble sort algorithm in Python
5+
"""Pure implementation of the bubble sort algorithm in Python (iterative).
6+
7+
Bubble sort works by repeatedly stepping through the collection,
8+
comparing each pair of adjacent elements and swapping them if they
9+
are in the wrong order. This process repeats, with each full pass
10+
"bubbling" the next-largest unsorted element into its correct
11+
position at the end of the collection, until a full pass completes
12+
with no swaps, at which point the collection is sorted.
13+
14+
Time complexity: O(n) best case (already sorted, thanks to the
15+
early-exit optimization), O(n^2) average and worst case.
16+
Space complexity: O(1) auxiliary (sorts in place).
617
718
:param collection: some mutable ordered collection with heterogeneous
819
comparable items inside
@@ -61,7 +72,19 @@ def bubble_sort_iterative(collection: list[Any]) -> list[Any]:
6172

6273

6374
def bubble_sort_recursive(collection: list[Any]) -> list[Any]:
64-
"""It is similar iterative bubble sort but recursive.
75+
"""Pure implementation of the bubble sort algorithm in Python (recursive).
76+
77+
Functionally identical to the iterative version: each call makes a
78+
single pass through the collection, comparing adjacent elements and
79+
swapping any pair that is out of order. If any swap occurred during
80+
the pass, the function calls itself again on the (partially sorted)
81+
collection; once a pass completes with no swaps, the collection is
82+
sorted and the recursion stops.
83+
84+
Time complexity: O(n) best case (already sorted), O(n^2) average and
85+
worst case.
86+
Space complexity: O(1) auxiliary for the sort itself (sorts in place),
87+
though the recursion adds O(n) call-stack frames in the worst case.
6588
6689
:param collection: mutable ordered sequence of elements
6790
:return: the same list in ascending order

web_programming/download_images_from_google_query.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,11 @@ def download_images_from_google_query(query: str = "dhaka", max_images: int = 5)
8888
opener.addheaders = [
8989
(
9090
"User-Agent",
91-
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
92-
" (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.19582",
91+
(
92+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
93+
" (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36"
94+
" Edge/18.19582"
95+
),
9396
)
9497
]
9598
urllib.request.install_opener(opener)

0 commit comments

Comments
 (0)