From a48e8edfe59b646fbcc820d96ed6c79a6c455239 Mon Sep 17 00:00:00 2001 From: Zo Bot Date: Mon, 20 Apr 2026 21:35:16 +0000 Subject: [PATCH 1/3] fix: clarify contribution guidelines --- .github/workflows/build.yml | 2 +- .github/workflows/devcontainer_ci.yml | 2 +- .github/workflows/directory_writer.yml | 2 +- .github/workflows/project_euler.yml | 4 ++-- .github/workflows/ruff.yml | 2 +- .github/workflows/sphinx.yml | 2 +- .pre-commit-config.yaml | 4 ++-- CONTRIBUTING.md | 4 ++-- DIRECTORY.md | 4 ---- pyproject.toml | 6 +++--- sorts/tim_sort.py | 13 +++++-------- 11 files changed, 19 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 62b62d0f6481..2bb8e1d69217 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - run: sudo apt-get update && sudo apt-get install -y libhdf5-dev - - uses: actions/checkout@v7 + - uses: actions/checkout@v6 - uses: astral-sh/setup-uv@v7 with: enable-cache: true diff --git a/.github/workflows/devcontainer_ci.yml b/.github/workflows/devcontainer_ci.yml index e8cd040c1323..d1b81593866f 100644 --- a/.github/workflows/devcontainer_ci.yml +++ b/.github/workflows/devcontainer_ci.yml @@ -12,7 +12,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v7 + - uses: actions/checkout@v6 - uses: devcontainers/ci@v0.3 with: push: never diff --git a/.github/workflows/directory_writer.yml b/.github/workflows/directory_writer.yml index 598cdfa5a371..deffbe9e364f 100644 --- a/.github/workflows/directory_writer.yml +++ b/.github/workflows/directory_writer.yml @@ -6,7 +6,7 @@ jobs: directory_writer: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v7 + - uses: actions/checkout@v6 with: fetch-depth: 0 - uses: actions/setup-python@v6 diff --git a/.github/workflows/project_euler.yml b/.github/workflows/project_euler.yml index ff61367974f3..591b2163cc1a 100644 --- a/.github/workflows/project_euler.yml +++ b/.github/workflows/project_euler.yml @@ -21,7 +21,7 @@ jobs: libxml2-dev libxslt-dev libhdf5-dev libopenblas-dev - - uses: actions/checkout@v7 + - uses: actions/checkout@v6 - uses: astral-sh/setup-uv@v7 - uses: actions/setup-python@v6 with: @@ -39,7 +39,7 @@ jobs: libxml2-dev libxslt-dev libhdf5-dev libopenblas-dev - - uses: actions/checkout@v7 + - uses: actions/checkout@v6 - uses: astral-sh/setup-uv@v7 - uses: actions/setup-python@v6 with: diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index d665d0fb9266..13df19c8d743 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -11,6 +11,6 @@ jobs: ruff: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v7 + - uses: actions/checkout@v6 - uses: astral-sh/setup-uv@v7 - run: uvx ruff check --output-format=github . diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index 7a8fc9460446..3f00094e0264 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -32,7 +32,7 @@ jobs: libxml2-dev libxslt-dev libhdf5-dev libopenblas-dev - - uses: actions/checkout@v7 + - uses: actions/checkout@v6 - uses: astral-sh/setup-uv@v7 - uses: actions/setup-python@v6 with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b865f88350ea..39daf3dd7f88 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ repos: - id: auto-walrus - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.15 + rev: v0.15.9 hooks: - id: ruff-check - id: ruff-format @@ -32,7 +32,7 @@ repos: - tomli - repo: https://github.com/tox-dev/pyproject-fmt - rev: v2.23.0 + rev: v2.21.0 hooks: - id: pyproject-fmt diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index aa6bff3ad1da..176dfaa76723 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ ## Before contributing -Welcome to [TheAlgorithms/Python](https://github.com/TheAlgorithms/Python)! Before submitting your pull requests, please ensure that you __read the whole guidelines__. If you have any doubts about the contributing guide, please feel free to [state it clearly in an issue](https://github.com/TheAlgorithms/Python/issues/new) or ask the community on [Gitter](https://gitter.im/TheAlgorithms/community). +Welcome to [TheAlgorithms/Python](https://github.com/TheAlgorithms/Python)! Before submitting your pull requests, please ensure that you __read the whole guidelines carefully__. If you have any doubts about the contributing guide, please feel free to [state it clearly in an issue](https://github.com/TheAlgorithms/Python/issues/new) or ask the community on [Gitter](https://gitter.im/TheAlgorithms/community). ## Contributing @@ -21,7 +21,7 @@ __Improving comments__ and __writing proper tests__ are also highly welcome. ### Contribution -We appreciate any contribution, from fixing a grammar mistake in a comment to implementing complex algorithms. Please read this section if you are contributing your work. +We appreciate any contribution, from fixing a grammatical mistake in a comment to implementing complex algorithms. Please read this section if you are contributing your work. Your contribution will be tested by our [automated testing on GitHub Actions](https://github.com/TheAlgorithms/Python/actions) to save time and mental energy. After you have submitted your pull request, you should see the GitHub Actions tests start to run at the bottom of your submission page. If those tests fail, then click on the ___details___ button to read through the GitHub Actions output to understand the failure. If you do not understand, please leave a comment on your submission page and a community member will try to help. diff --git a/DIRECTORY.md b/DIRECTORY.md index daf71bab8162..ca454bd5fd82 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -471,8 +471,6 @@ * [Geometry](geometry/geometry.py) * [Graham Scan](geometry/graham_scan.py) * [Jarvis March](geometry/jarvis_march.py) - * [Ramer Douglas Peucker](geometry/ramer_douglas_peucker.py) - * [Segment Intersection](geometry/segment_intersection.py) * Tests * [Test Graham Scan](geometry/tests/test_graham_scan.py) * [Test Jarvis March](geometry/tests/test_jarvis_march.py) @@ -525,7 +523,6 @@ * [Graphs Floyd Warshall](graphs/graphs_floyd_warshall.py) * [Greedy Best First](graphs/greedy_best_first.py) * [Greedy Min Vertex Cover](graphs/greedy_min_vertex_cover.py) - * [Johnson](graphs/johnson.py) * [Kahns Algorithm Long](graphs/kahns_algorithm_long.py) * [Kahns Algorithm Topo](graphs/kahns_algorithm_topo.py) * [Karger](graphs/karger.py) @@ -546,7 +543,6 @@ * [Strongly Connected Components](graphs/strongly_connected_components.py) * [Tarjans Scc](graphs/tarjans_scc.py) * Tests - * [Test Johnson](graphs/tests/test_johnson.py) * [Test Min Spanning Tree Kruskal](graphs/tests/test_min_spanning_tree_kruskal.py) * [Test Min Spanning Tree Prim](graphs/tests/test_min_spanning_tree_prim.py) diff --git a/pyproject.toml b/pyproject.toml index 0b0c3f5cfda4..34e099a46435 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -169,14 +169,14 @@ skip = """\ python_version = "3.14" [tool.pytest] +ini_options.markers = [ + "mat_ops: mark a test as utilizing matrix operations.", +] ini_options.addopts = [ "--durations=10", "--doctest-modules", "--showlocals", ] -ini_options.markers = [ - "mat_ops: mark a test as utilizing matrix operations.", -] [tool.coverage] report.omit = [ diff --git a/sorts/tim_sort.py b/sorts/tim_sort.py index 2eeed88b7399..41ab4a10a87b 100644 --- a/sorts/tim_sort.py +++ b/sorts/tim_sort.py @@ -1,7 +1,4 @@ -from typing import Any - - -def binary_search(lst: list[Any], item: Any, start: int, end: int) -> int: +def binary_search(lst, item, start, end): if start == end: return start if lst[start] > item else start + 1 if start > end: @@ -16,7 +13,7 @@ def binary_search(lst: list[Any], item: Any, start: int, end: int) -> int: return mid -def insertion_sort(lst: list[Any]) -> list[Any]: +def insertion_sort(lst): length = len(lst) for index in range(1, length): @@ -27,7 +24,7 @@ def insertion_sort(lst: list[Any]) -> list[Any]: return lst -def merge(left: list[Any], right: list[Any]) -> list[Any]: +def merge(left, right): if not left: return right @@ -40,7 +37,7 @@ def merge(left: list[Any], right: list[Any]) -> list[Any]: return [right[0], *merge(left, right[1:])] -def tim_sort(lst: list[Any] | tuple[Any, ...] | str) -> list[Any]: +def tim_sort(lst): """ >>> tim_sort("Python") ['P', 'h', 'n', 'o', 't', 'y'] @@ -56,7 +53,7 @@ def tim_sort(lst: list[Any] | tuple[Any, ...] | str) -> list[Any]: length = len(lst) runs, sorted_runs = [], [] new_run = [lst[0]] - sorted_array: list[Any] = [] + sorted_array = [] i = 1 while i < length: if lst[i] < lst[i - 1]: From d2bed0d92ba6194cbbad7f6092bb62306c68282c Mon Sep 17 00:00:00 2001 From: Zo Bot Date: Fri, 22 May 2026 01:32:56 +0000 Subject: [PATCH 2/3] display the computed negative instead of the original image in convert_to_negative --- digital_image_processing/convert_to_negative.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/digital_image_processing/convert_to_negative.py b/digital_image_processing/convert_to_negative.py index 9bf2d8f2c075..227aab51bc54 100644 --- a/digital_image_processing/convert_to_negative.py +++ b/digital_image_processing/convert_to_negative.py @@ -25,6 +25,6 @@ def convert_to_negative(img): neg = convert_to_negative(img) # show result image - imshow("negative of original image", img) + imshow("negative of original image", neg) waitKey(0) destroyAllWindows() From 82ce392fa6e199da948477abe34fdaa206cf9f80 Mon Sep 17 00:00:00 2001 From: Zo Bot Date: Fri, 19 Jun 2026 15:27:35 +0000 Subject: [PATCH 3/3] =?UTF-8?q?remove=20dead=20try/except=20wrapper=20arou?= =?UTF-8?q?nd=20mass=20*=20acceleration=20in=20newtons=5Fsecond=5Flaw=5Fof?= =?UTF-8?q?=5Fmotion=20=E2=80=94=20the=20function=20signature=20is=20annot?= =?UTF-8?q?ated=20(mass:=20float,=20acceleration:=20float)=20->=20float,?= =?UTF-8?q?=20and=20multiplying=20two=20float=20values=20cannot=20raise=20?= =?UTF-8?q?any=20exception=20on=20valid=20inputs.=20The=20previous=20'try:?= =?UTF-8?q?=20force=20=3D=20mass=20*=20acceleration;=20except=20Exception:?= =?UTF-8?q?=20return=20-0.0'=20wrapper=20was=20dead=20code=20that=20silent?= =?UTF-8?q?ly=20masked=20TypeError=20when=20a=20caller=20violated=20the=20?= =?UTF-8?q?type=20contract=20(e.g.=20passing=20a=20string),=20KeyboardInte?= =?UTF-8?q?rrupt,=20SystemExit,=20and=20any=20unrelated=20bug=20in=20this?= =?UTF-8?q?=20function=20body,=20by=20returning=20the=20unusual=20signed?= =?UTF-8?q?=20zero=20-0.0=20which=20can=20poison=20downstream=20numerical?= =?UTF-8?q?=20code=20(-0.0=20=3D=3D=200.0=20in=20equality=20checks=20but?= =?UTF-8?q?=20is=20distinct=20in=20repr=20and=20bit=20pattern).=20The=20pl?= =?UTF-8?q?ain=20expression=20makes=20the=20implementation=20match=20its?= =?UTF-8?q?=20type=20signature=20and=20its=20existing=20doctests;=20the=20?= =?UTF-8?q?two=20doctests=20still=20pass=20(100=20and=202.0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- physics/newtons_second_law_of_motion.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/physics/newtons_second_law_of_motion.py b/physics/newtons_second_law_of_motion.py index 4149e2494f31..58336acb5c76 100644 --- a/physics/newtons_second_law_of_motion.py +++ b/physics/newtons_second_law_of_motion.py @@ -71,12 +71,7 @@ def newtons_second_law_of_motion(mass: float, acceleration: float) -> float: >>> newtons_second_law_of_motion(2.0, 1) 2.0 """ - force = 0.0 - try: - force = mass * acceleration - except Exception: - return -0.0 - return force + return mass * acceleration if __name__ == "__main__":