Skip to content

Fix type hints in sorts/tim_sort.py, relates to #14457#14474

Merged
poyea merged 14 commits into
TheAlgorithms:masterfrom
ale-molinari:fix-timsort-typehints
May 18, 2026
Merged

Fix type hints in sorts/tim_sort.py, relates to #14457#14474
poyea merged 14 commits into
TheAlgorithms:masterfrom
ale-molinari:fix-timsort-typehints

Conversation

@ale-molinari
Copy link
Copy Markdown
Contributor

Describe your change:

Added missing type hints (using the | operator for int | float compatibility) to the functions in sorts/tim_sort.py to resolve the typing errors reported by the astral.sh scan.

Fixes #14457

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Add or change doctests? -- Note: Please avoid changing both code and 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.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • 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. (N/A)
  • 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".

@algorithms-keeper algorithms-keeper Bot added enhancement This PR modified some existing files awaiting reviews This PR is ready to be reviewed labels Mar 28, 2026
@algorithms-keeper algorithms-keeper Bot added the tests are failing Do not merge until tests pass label Mar 28, 2026
@algorithms-keeper algorithms-keeper Bot removed the tests are failing Do not merge until tests pass label Mar 28, 2026
@algorithms-keeper algorithms-keeper Bot added tests are failing Do not merge until tests pass and removed tests are failing Do not merge until tests pass labels Mar 28, 2026
@algorithms-keeper algorithms-keeper Bot added the tests are failing Do not merge until tests pass label Mar 28, 2026
@algorithms-keeper algorithms-keeper Bot removed the tests are failing Do not merge until tests pass label Mar 28, 2026
@algorithms-keeper algorithms-keeper Bot added tests are failing Do not merge until tests pass and removed tests are failing Do not merge until tests pass labels Mar 28, 2026
@ale-molinari
Copy link
Copy Markdown
Contributor Author

Fixed all type hint issues and resolved mypy conflicts using Any to handle complex sorting logic. All tests are now passing!

@poyea poyea self-assigned this May 18, 2026
@poyea poyea requested a review from Copilot May 18, 2026 22:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sorts/tim_sort.py
@poyea poyea enabled auto-merge (squash) May 18, 2026 22:14
@poyea poyea merged commit 144ef9c into TheAlgorithms:master May 18, 2026
9 checks passed
@algorithms-keeper algorithms-keeper Bot removed the awaiting reviews This PR is ready to be reviewed label May 18, 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.

Python type hints with ty

3 participants