Skip to content

typing: un-ignore parameter-already-assigned - #15308

Closed
deerred643-star wants to merge 1 commit into
TheAlgorithms:masterfrom
deerred643-star:fix-ty-parameter-already-assigned
Closed

deerred643-star wants to merge 1 commit into
TheAlgorithms:masterfrom
deerred643-star:fix-ty-parameter-already-assigned

Conversation

@deerred643-star

Copy link
Copy Markdown
Contributor

Un-ignores parameter-already-assigned as part of the ty gradual-typing baseline.

ty check --exclude-scripts --error parameter-already-assigned on a synced Python 3.14 env reported exactly one diagnostic, in machine_learning/k_means_clust.py:

error[parameter-already-assigned]: Multiple values provided for parameter `s` of bound method `Axes.scatter`
   --> machine_learning/k_means_clust.py:163:69
    |
163 |         centroids[:, 0], centroids[:, 1], centroids[:, 2], c="red", s=100, marker="x"
    |                                                                     ^^^^^

plt.axes(projection="3d") is annotated as returning the 2D Axes, whose scatter signature is (x, y, s=None, c=None, ...), so the third positional argument binds to s and collides with s=100. At runtime the object is an Axes3D, whose signature is (xs, ys, zs=0, zdir="z", s=20, c=None, ...), so the call is valid: this is a false positive caused by the imprecise static return type of plt.axes, not a latent TypeError.

The fix passes the third coordinate explicitly as zs=, which is a positional-or-keyword parameter of Axes3D.scatter. This keeps the runtime behaviour identical (verified by rendering the plot under the Agg backend before and after and comparing offsets, marker sizes, face colours and marker paths — byte-for-byte identical), and avoids Any, cast, new imports, and suppression comments.

With the diagnostic count at zero, rules.parameter-already-assigned = "ignore" is removed from [tool.ty]. No other rule severity is touched.

Validation

  • ty check --exclude-scripts: Found 5 -> Found 4 diagnostics; parameter-already-assigned: 1 -> 0. The 4 remaining diagnostics are pre-existing (redundant-condition x2, invalid-assignment x2) and untouched.
  • Full run including PEP 723 scripts: Found 50 -> Found 49; parameter-already-assigned: 1 -> 0.
  • ruff check machine_learning/k_means_clust.py — all checks passed
  • ruff format --check machine_learning/k_means_clust.py — already formatted
  • ruff check pyproject.toml — all checks passed
  • pytest --doctest-modules machine_learning/k_means_clust.py — 5 passed

Part of #15187

@algorithms-keeper algorithms-keeper Bot added the awaiting reviews This PR is ready to be reviewed label Sep 12, 2026
@algorithms-keeper

Copy link
Copy Markdown

Closing this pull request as invalid

@deerred643-star, this pull request is being closed as none of the checkboxes have been marked. It is important that you go through the checklist and mark the ones relevant to this pull request. Please read the Contributing guidelines.

If you're facing any problem on how to mark a checkbox, please read the following instructions:

  • Read a point one at a time and think if it is relevant to the pull request or not.
  • If it is, then mark it by putting a x between the square bracket like so: [x]

NOTE: Only [x] is supported so if you have put any other letter or symbol between the brackets, that will be marked as invalid. If that is the case then please open a new pull request with the appropriate changes.

@algorithms-keeper algorithms-keeper Bot removed the awaiting reviews This PR is ready to be reviewed label Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant