Skip to content

ty: un-ignore unsupported-operator rule - #15599

Closed
SirHumza wants to merge 1 commit into
TheAlgorithms:masterfrom
SirHumza:ty/un-ignore-unsupported-operator
Closed

SirHumza wants to merge 1 commit into
TheAlgorithms:masterfrom
SirHumza:ty/un-ignore-unsupported-operator

Conversation

@SirHumza

Copy link
Copy Markdown

Describe your change

  • 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?

Contributes to #15187.

Removes rules.unsupported-operator = "ignore" from [tool.ty]. On a synced Python 3.15 (regular GIL) environment the rule now reports zero diagnostics, so it can be enforced without any new findings.

Files fixed:

  • sorts/iterative_merge_sort.py, sorts/quick_sort_3_partition.py, sorts/recursive_quick_sort.py -- the local Comparable protocols only declared the dunder used in one spot, so the operators at the call sites were flagged as unsupported. Declared the missing dunders (__le__, __ge__, __gt__ respectively), matching the pattern in sorts/merge_sort.py / sorts/quick_sort.py.
  • computer_vision/mean_threshold.py -- Image.load() is PixelAccess | None and grayscale pixels are read as float | tuple[int, ...], so the average/compare-and-write loops tripped unsupported-operator (plus an invalid-assignment on the None subscript). Added a None guard and narrowed the pixel to a numeric value, scoped to the grayscale images the docstring already requires.
  • web_programming/get_amazon_product_data.py -- build the product link with an f-string instead of "prefix" + item.h2.a["href"], since the attribute value is not statically str. Matches the f-string already used at line 28.

Verification (uv sync --python 3.15, then uv run --python 3.15 --with ty ty check):

  • No unsupported-operator diagnostics remain and the total diagnostic count does not increase.
  • doctests: sorts/iterative_merge_sort.py 16 passed, sorts/quick_sort_3_partition.py 39 passed, sorts/recursive_quick_sort.py 9 passed, computer_vision/mean_threshold.py passed.
  • ruff check and ruff format --check clean on the touched files.

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.
  • 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".

@SirHumza
SirHumza requested a review from cclauss as a code owner October 18, 2026 13:22
@algorithms-keeper algorithms-keeper Bot added awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files labels Oct 18, 2026
@SirHumza SirHumza closed this by deleting the head repository Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant