From b2cc7c821aa6804b8dd705be8e3bdd79ea00c716 Mon Sep 17 00:00:00 2001 From: HasanGenis Date: Mon, 28 Sep 2026 17:24:24 +0300 Subject: [PATCH] ty: un-ignore parameter-already-assigned (1 file, 1 spot) plt.axes(projection="3d") is typed to return the base 2D Axes, so ax.scatter's 3rd positional arg (meant as zs) was resolving against 2D Axes.scatter's `s` parameter and colliding with the explicit s=100 kwarg. Cast ax to Axes3D so ty resolves the correct (xs, ys, zs, ...) overload instead. Part of #15187 --- machine_learning/k_means_clust.py | 7 ++++++- pyproject.toml | 1 - 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/machine_learning/k_means_clust.py b/machine_learning/k_means_clust.py index 19e510b966b6..1df0985570bf 100644 --- a/machine_learning/k_means_clust.py +++ b/machine_learning/k_means_clust.py @@ -48,10 +48,12 @@ """ import warnings +from typing import cast import numpy as np import pandas as pd from matplotlib import pyplot as plt +from mpl_toolkits.mplot3d import Axes3D from sklearn.metrics import pairwise_distances warnings.filterwarnings("ignore") @@ -157,7 +159,10 @@ def plot_heterogeneity(heterogeneity, k) -> None: def plot_kmeans(data, centroids, cluster_assignment) -> None: - ax = plt.axes(projection="3d") + # plt.axes() is typed to return the base 2D Axes, but projection="3d" makes + # it an Axes3D at runtime; cast so ty resolves Axes3D.scatter's (xs, ys, zs) + # signature instead of colliding its 3rd positional arg with the `s` kwarg. + ax = cast(Axes3D, plt.axes(projection="3d")) ax.scatter(data[:, 0], data[:, 1], data[:, 2], c=cluster_assignment, cmap="viridis") ax.scatter( centroids[:, 0], centroids[:, 1], centroids[:, 2], c="red", s=100, marker="x" diff --git a/pyproject.toml b/pyproject.toml index 52bd60b9d3aa..46a1d3295837 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -323,7 +323,6 @@ rules.invalid-return-type = "ignore" rules.no-matching-overload = "ignore" rules.not-iterable = "ignore" rules.not-subscriptable = "ignore" -rules.parameter-already-assigned = "ignore" rules.unresolved-attribute = "ignore" rules.unresolved-import = "ignore" rules.unsupported-operator = "ignore"