Skip to content

MNT update to mypy=1.3 #26632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 20, 2023
Merged

MNT update to mypy=1.3 #26632

merged 2 commits into from
Jun 20, 2023

Conversation

adrinjalali
Copy link
Member

mypy has gotten a lot faster in the meantime.

@github-actions
Copy link

github-actions bot commented Jun 20, 2023

Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

Here is the patch to avoid using # type: ignore:

diff --git a/sklearn/cluster/_hdbscan/hdbscan.py b/sklearn/cluster/_hdbscan/hdbscan.py
index 3d8ec08ac3..f1584f46d6 100644
--- a/sklearn/cluster/_hdbscan/hdbscan.py
+++ b/sklearn/cluster/_hdbscan/hdbscan.py
@@ -62,7 +62,7 @@ FAST_METRICS = set(KDTree.valid_metrics() + BallTree.valid_metrics())
 # Encodings are arbitrary but must be strictly negative.
 # The current encodings are chosen as extensions to the -1 noise label.
 # Avoided enums so that the end user only deals with simple labels.
-_OUTLIER_ENCODING = {
+_OUTLIER_ENCODING: dict = {
     "infinite": {
         "label": -2,
         # The probability could also be 1, since infinite points are certainly
diff --git a/sklearn/cluster/tests/test_hdbscan.py b/sklearn/cluster/tests/test_hdbscan.py
index c21b188fd5..b652a99aa2 100644
--- a/sklearn/cluster/tests/test_hdbscan.py
+++ b/sklearn/cluster/tests/test_hdbscan.py
@@ -34,9 +34,7 @@ ALGORITHMS = [
     "auto",
 ]
 
-OUTLIER_SET = {-1} | {
-    out["label"] for _, out in _OUTLIER_ENCODING.items()  # type: ignore
-}
+OUTLIER_SET = {-1} | {out["label"] for _, out in _OUTLIER_ENCODING.items()}
 
 
 @pytest.mark.parametrize("outlier_type", _OUTLIER_ENCODING)
diff --git a/sklearn/tests/test_metaestimators_metadata_routing.py b/sklearn/tests/test_metaestimators_metadata_routing.py
index 1cd21ae817..5160a4b46b 100644
--- a/sklearn/tests/test_metaestimators_metadata_routing.py
+++ b/sklearn/tests/test_metaestimators_metadata_routing.py
@@ -171,7 +171,7 @@ class ConsumingClassifier(ClassifierMixin, BaseEstimator):
         # return np.zeros(shape=(len(X), 2))
 
 
-METAESTIMATORS = [
+METAESTIMATORS: list = [
     {
         "metaestimator": MultiOutputRegressor,
         "estimator_name": "estimator",
@@ -232,9 +232,7 @@ The keys are as follows:
 """
 
 # ids used for pytest fixture
-METAESTIMATOR_IDS = [
-    str(row["metaestimator"].__name__) for row in METAESTIMATORS  # type: ignore
-]
+METAESTIMATOR_IDS = [str(row["metaestimator"].__name__) for row in METAESTIMATORS]
 
 
 def test_registry_copy():

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

LGTM

@ogrisel ogrisel merged commit 4655d8b into scikit-learn:main Jun 20, 2023
@adrinjalali adrinjalali deleted the mypy branch June 20, 2023 16:02
jeremiedbb pushed a commit to jeremiedbb/scikit-learn that referenced this pull request Jun 29, 2023
jeremiedbb pushed a commit that referenced this pull request Jun 29, 2023
REDVM pushed a commit to REDVM/scikit-learn that referenced this pull request Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants