Skip to content

Remove unused TypeVar from bubble sort - #15491

Merged
cclauss merged 1 commit into
TheAlgorithms:masterfrom
HarshRajSinghania:bubble-sort-drop-unused-typevar
Oct 4, 2026
Merged

cclauss merged 1 commit into
TheAlgorithms:masterfrom
HarshRajSinghania:bubble-sort-drop-unused-typevar

Conversation

@HarshRajSinghania

Copy link
Copy Markdown
Contributor

Describe your change

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Add or change doctests? -- Note: Please avoid changing both the logic and the tests in a single pull request.
  • Documentation change?

Checklist

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase or snake_case (no spaces or hyphens).
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • If this pull request resolves one or more open issues then the description above includes the issue number(s) with a closing keyword: Fixes #ISSUE-NUMBER.

Summary
sorts/bubble_sort.py still imported TypeVar and assigned T = TypeVar("T", bound=Comparable) even though both functions already use PEP 695 parameters (def bubble_sort_iterative[T: Comparable] and def bubble_sort_recursive[T: Comparable]). That module-level TypeVar is unused.

Motivation
Follow-up requested on #15234: drop the leftover TypeVar step now that the comparison sorts use a bounded type parameter. This PR only covers bubble_sort.py.

Implementation
Removed the TypeVar import and the unused T = TypeVar(...) assignment. The Comparable protocol and the existing function signatures are unchanged.

Testing
uv run --python 3.12 python -m doctest -v sorts/bubble_sort.py
42 tests passed, 0 failed.
uv run --python 3.12 python -m py_compile sorts/bubble_sort.py succeeded.

Refs #15234

The PEP 695 type parameters already bound T to Comparable, so the module-level TypeVar was unused. Matches the cleanup requested in TheAlgorithms#15234.
@algorithms-keeper algorithms-keeper Bot added awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files labels Oct 4, 2026

@cclauss cclauss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uv run --python 3.12

This repo only supports Python >= 3.15t

@cclauss
cclauss merged commit 50dff2c into TheAlgorithms:master Oct 4, 2026
6 checks passed
@algorithms-keeper algorithms-keeper Bot removed awaiting reviews This PR is ready to be reviewed labels Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement This PR modified some existing files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants