Skip to content

Disallow blanket ignores and remove unused noqa #382

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ target-version = "py39"
extend-select = [
"FA", # flake8-future-annotations
"I", # isort
"PGH", # pygrep-hooks
"PGH", # pygrep-hooks and blanket-noqa
"PIE790", # unnecessary-placeholder
"PYI", # flake8-pyi
"RUF", # Ruff-specific and unused-noqa
"UP", # pyupgrade
"W", # pycodestyle Warning
"PIE790", # unnecessary-placeholder
]
ignore = [
###
Expand All @@ -82,6 +85,11 @@ ignore = [

[tool.ruff.lint.per-file-ignores]
"*.pyi" = [
# Ruff 0.8.0 added sorting of __all__ and __slots_.
# There is no consensus in typeshed on whether they want to apply this to stubs, so keeping the status quo.
# See https://github.com/python/typeshed/pull/13108
"RUF022", # `__all__` is not sorted
"RUF023", # `{}.__slots__` is not sorted
###
# Rules that are out of the control of stub authors:
###
Expand Down
8 changes: 4 additions & 4 deletions stubs/matplotlib/backends/backend_qt.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class FigureCanvasQT(QtWidgets.QWidget, FigureCanvasBase):
def keyPressEvent(self, event) -> None: ...
def keyReleaseEvent(self, event) -> None: ...
def resizeEvent(self, event) -> None: ...
def sizeHint(self) -> QtCore.QSize: ... # type: ignore
def minumumSizeHint(self) -> QtCore.QSize: ... # type: ignore
def sizeHint(self) -> QtCore.QSize: ... # type: ignore[name-defined]
def minumumSizeHint(self) -> QtCore.QSize: ... # type: ignore[name-defined]
def flush_events(self) -> None: ...
def start_event_loop(self, timeout=...) -> None: ...
def stop_event_loop(self, event=...) -> None: ...
Expand All @@ -58,7 +58,7 @@ class FigureCanvasQT(QtWidgets.QWidget, FigureCanvasBase):
def drawRectangle(self, rect) -> None: ...

class MainWindow(QtWidgets.QMainWindow):
closing: QtCore.Signal = ... # type: ignore
closing: QtCore.Signal = ... # type: ignore[name-defined]
def closeEvent(self, event) -> None: ...

class FigureManagerQT(FigureManagerBase):
Expand All @@ -71,7 +71,7 @@ class FigureManagerQT(FigureManagerBase):
def set_window_title(self, title) -> None: ...

class NavigationToolbar2QT(NavigationToolbar2, QtWidgets.QToolBar):
message: QtCore.Signal = ... # type: ignore
message: QtCore.Signal = ... # type: ignore[name-defined]
toolitems: list = ...
def __init__(self, canvas, parent=..., coordinates=...) -> None: ...
def edit_parameters(self) -> None: ...
Expand Down
7 changes: 1 addition & 6 deletions stubs/networkx/algorithms/approximation/kcomponents.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import itertools
from collections import defaultdict
from collections.abc import Mapping
from functools import cached_property

from ...classes.graph import Graph
from ...exception import NetworkXError
from ...utils import not_implemented_for
from . import local_node_connectivity

__all__ = ["k_components"]

Expand All @@ -17,7 +12,7 @@ class _AntiGraph(Graph):

def single_edge_dict(self): ...

edge_attr_dict_factory = single_edge_dict # type: ignore
edge_attr_dict_factory = single_edge_dict

def __getitem__(self, n) -> Mapping: ...
def neighbors(self, n): ...
Expand Down
11 changes: 3 additions & 8 deletions stubs/networkx/classes/digraph.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
from copy import deepcopy
from functools import cached_property

import networkx.convert as convert

from ..classes.coreviews import AdjacencyView
from ..classes.graph import Graph
from ..classes.reportviews import DiDegreeView, InDegreeView, InEdgeView, OutDegreeView, OutEdgeView
from ..exception import NetworkXError
from ..classes.reportviews import DiDegreeView, InEdgeView, OutEdgeView

__all__ = ["DiGraph"]

Expand All @@ -18,8 +13,8 @@ class _CachedPropertyResetterPred:

class DiGraph(Graph):
graph = ...
_adj = ... # type: ignore
_succ = ... # type: ignore
_adj = ...
_succ = ...
_pred = ...

def __init__(self, incoming_graph_data=None, **attr): ...
Expand Down
15 changes: 1 addition & 14 deletions stubs/networkx/utils/decorators.pyi
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
import bz2
import collections
import gzip
import inspect
import itertools
import re
from collections import defaultdict
from collections.abc import Sequence
from contextlib import contextmanager
from os.path import splitext
from pathlib import Path
from typing import Callable

from ..classes.graph import Graph
from ..utils import create_py_random_state, create_random_state

__all__ = [
"not_implemented_for",
"open_file",
Expand All @@ -30,7 +17,7 @@ def not_implemented_for(*graph_types): ...
# To handle new extensions, define a function accepting a `path` and `mode`.
# Then add the extension to _dispatch_dict.
fopeners: dict = ...
_dispatch_dict = ... # type: ignore
_dispatch_dict = ...

def open_file(path_arg: str | int, mode: str = "r"): ...
def nodes_or_number(which_args: str | int | Sequence[str]): ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/skimage/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ._shared import lazy as lazy
from ._shared.tester import PytestTester as PytestTester # noqa
from ._shared.tester import PytestTester as PytestTester
from ._shared.version_requirements import ensure_python_version as ensure_python_version

__version__: str = ...
Expand Down
2 changes: 0 additions & 2 deletions stubs/skimage/data/_registry.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# flake8: noqa

# This minimal dataset was available as part of
# scikit-image 0.15 and will be retained until
# further notice.
Expand Down
3 changes: 0 additions & 3 deletions stubs/sklearn/_build_utils/openmp_helpers.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
# This code is adapted for a large part from the astropy openmp helpers, which
# can be found at: https://github.com/astropy/extension-helpers/blob/master/extension_helpers/_openmp_helpers.py # noqa

def get_openmp_flag(compiler): ...
def check_openmp_support(): ...
16 changes: 0 additions & 16 deletions stubs/sklearn/decomposition/_dict_learning.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,7 @@ from numpy.random import RandomState

from .._typing import ArrayLike, Float, Int, MatrixLike
from ..base import BaseEstimator, ClassNamePrefixFeaturesOutMixin, TransformerMixin
from ..utils import (
deprecated,
)

# Author: Vlad Niculae, Gael Varoquaux, Alexandre Gramfort
# License: BSD 3 clause

# XXX : could be moved to the linear_model module
def sparse_encode(
X: ArrayLike,
dictionary: MatrixLike,
Expand Down Expand Up @@ -180,15 +173,6 @@ class MiniBatchDictionaryLearning(_BaseSparseCoding, BaseEstimator):
tol: Float = 1e-3,
max_no_improvement: Int = 10,
) -> None: ...
@deprecated("The attribute `iter_offset_` is deprecated in 1.1 and will be removed in 1.3.") # type: ignore
@property
def iter_offset_(self) -> int: ...
@deprecated("The attribute `random_state_` is deprecated in 1.1 and will be removed in 1.3.") # type: ignore
@property
def random_state_(self) -> RandomState: ...
@deprecated("The attribute `inner_stats_` is deprecated in 1.1 and will be removed in 1.3.") # type: ignore
@property
def inner_stats_(self) -> tuple[ndarray, ndarray]: ...
def fit(self, X: MatrixLike, y: Any = None) -> Self: ...
def partial_fit(
self,
Expand Down
9 changes: 0 additions & 9 deletions stubs/sklearn/decomposition/_pca.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ from numpy import ndarray
from numpy.random import RandomState

from .._typing import Float, Int, MatrixLike
from ..utils.deprecation import deprecated
from ._base import _BasePCA

class PCA(_BasePCA):
Expand Down Expand Up @@ -35,14 +34,6 @@ class PCA(_BasePCA):
power_iteration_normalizer: Literal["auto", "QR", "LU", "none"] = "auto",
random_state: RandomState | None | Int = None,
) -> None: ...

# TODO(1.4): remove in 1.4
# mypy error: Decorated property not supported
@deprecated( # type: ignore
"Attribute `n_features_` was deprecated in version 1.2 and will be removed in 1.4. Use `n_features_in_` instead."
)
@property
def n_features_(self) -> int: ...
def fit(self, X: MatrixLike, y: Any = None) -> Self: ...
def fit_transform(self, X: MatrixLike, y: Any = None) -> ndarray: ...
def score_samples(self, X: MatrixLike) -> ndarray: ...
Expand Down
14 changes: 1 addition & 13 deletions stubs/sklearn/ensemble/_base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from typing_extensions import Self

from .._typing import Int
from ..base import BaseEstimator, MetaEstimatorMixin
from ..utils import Bunch, deprecated
from ..utils import Bunch
from ..utils.metaestimators import _BaseComposition

class BaseEnsemble(MetaEstimatorMixin, BaseEstimator, metaclass=ABCMeta):
Expand All @@ -23,18 +23,6 @@ class BaseEnsemble(MetaEstimatorMixin, BaseEstimator, metaclass=ABCMeta):
estimator_params: Sequence[str] = ...,
base_estimator: Any = "deprecated",
) -> None: ...

# TODO(1.4): remove
# mypy error: Decorated property not supported
@deprecated( # type: ignore
"Attribute `base_estimator_` was deprecated in version 1.2 and will be removed in 1.4. Use `estimator_` instead."
)
@property
def base_estimator_(self) -> BaseEstimator: ...

# TODO(1.4): remove
@property
def estimator_(self) -> BaseEstimator: ...
def __len__(self) -> int: ...
def __getitem__(self, index): ...
def __iter__(self): ...
Expand Down
6 changes: 0 additions & 6 deletions stubs/sklearn/ensemble/_gb.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ from numpy.random import RandomState

from .._typing import ArrayLike, Float, Int, MatrixLike
from ..base import BaseEstimator, ClassifierMixin, RegressorMixin
from ..utils import deprecated
from ._base import BaseEnsemble
from ._gb_losses import LossFunction

Expand Down Expand Up @@ -57,11 +56,6 @@ class BaseGradientBoosting(BaseEnsemble, metaclass=ABCMeta):
def feature_importances_(self) -> ndarray: ...
def apply(self, X: MatrixLike | ArrayLike) -> ndarray: ...

# TODO(1.3): Remove
# mypy error: Decorated property not supported
@deprecated("Attribute `loss_` was deprecated in version 1.1 and will be removed in 1.3.") # type: ignore
def loss_(self): ...

class GradientBoostingClassifier(ClassifierMixin, BaseGradientBoosting):
max_features_: int = ...
n_classes_: int = ...
Expand Down
5 changes: 0 additions & 5 deletions stubs/sklearn/linear_model/_glm/glm.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ from ..._loss.loss import (
)
from ..._typing import ArrayLike, Float, Int, MatrixLike
from ...base import BaseEstimator, RegressorMixin
from ...utils import deprecated

class _GeneralizedLinearRegressor(RegressorMixin, BaseEstimator):
_base_loss: BaseLoss = ...
Expand Down Expand Up @@ -46,10 +45,6 @@ class _GeneralizedLinearRegressor(RegressorMixin, BaseEstimator):
sample_weight: None | ArrayLike = None,
) -> Float: ...

# TODO(1.3): remove
@deprecated("Attribute `family` was deprecated in version 1.1 and will be removed in 1.3.") # type: ignore
def family(self): ...

class PoissonRegressor(_GeneralizedLinearRegressor):
n_iter_: int = ...
feature_names_in_: ndarray = ...
Expand Down
21 changes: 0 additions & 21 deletions stubs/sklearn/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1623,21 +1623,14 @@ sklearn.decomposition.FastICA.__init__
sklearn.decomposition.LatentDirichletAllocation.fit_transform
sklearn.decomposition.LatentDirichletAllocation.transform
sklearn.decomposition.MiniBatchDictionaryLearning.__init__
sklearn.decomposition.MiniBatchDictionaryLearning.inner_stats_
sklearn.decomposition.MiniBatchDictionaryLearning.iter_offset_
sklearn.decomposition.MiniBatchDictionaryLearning.partial_fit
sklearn.decomposition.MiniBatchDictionaryLearning.random_state_
sklearn.decomposition.MiniBatchNMF.__init__
sklearn.decomposition.MiniBatchSparsePCA.__init__
sklearn.decomposition.NMF.__init__
sklearn.decomposition.PCA.n_features_
sklearn.decomposition._dict_learning.DictionaryLearning.__init__
sklearn.decomposition._dict_learning.DictionaryLearning.fit_transform
sklearn.decomposition._dict_learning.MiniBatchDictionaryLearning.__init__
sklearn.decomposition._dict_learning.MiniBatchDictionaryLearning.inner_stats_
sklearn.decomposition._dict_learning.MiniBatchDictionaryLearning.iter_offset_
sklearn.decomposition._dict_learning.MiniBatchDictionaryLearning.partial_fit
sklearn.decomposition._dict_learning.MiniBatchDictionaryLearning.random_state_
sklearn.decomposition._dict_learning.dict_learning_online
sklearn.decomposition._fastica.FastICA.__init__
sklearn.decomposition._fastica.fastica
Expand All @@ -1650,7 +1643,6 @@ sklearn.decomposition._nmf._BaseNMF.__init__
sklearn.decomposition._nmf._BaseNMF.inverse_transform
sklearn.decomposition._nmf.non_negative_factorization
sklearn.decomposition._online_lda_fast.psi
sklearn.decomposition._pca.PCA.n_features_
sklearn.decomposition._sparse_pca.MiniBatchSparsePCA.__init__
sklearn.decomposition.dict_learning_online
sklearn.decomposition.fastica
Expand All @@ -1666,8 +1658,6 @@ sklearn.ensemble.BaggingClassifier.estimators_samples_
sklearn.ensemble.BaggingRegressor.__init__
sklearn.ensemble.BaggingRegressor.estimators_samples_
sklearn.ensemble.BaseEnsemble.__init__
sklearn.ensemble.BaseEnsemble.base_estimator_
sklearn.ensemble.BaseEnsemble.estimator_
sklearn.ensemble.ExtraTreesClassifier.__init__
sklearn.ensemble.ExtraTreesClassifier.feature_importances_
sklearn.ensemble.ExtraTreesRegressor.__init__
Expand Down Expand Up @@ -1702,8 +1692,6 @@ sklearn.ensemble._bagging.BaseBagging.estimators_samples_
sklearn.ensemble._bagging.BaseBagging.fit
sklearn.ensemble._bagging.MAX_INT
sklearn.ensemble._base.BaseEnsemble.__init__
sklearn.ensemble._base.BaseEnsemble.base_estimator_
sklearn.ensemble._base.BaseEnsemble.estimator_
sklearn.ensemble._forest.BaseForest.__init__
sklearn.ensemble._forest.ExtraTreesClassifier.__init__
sklearn.ensemble._forest.ExtraTreesClassifier.feature_importances_
Expand All @@ -1717,7 +1705,6 @@ sklearn.ensemble._forest.RandomForestClassifier.feature_importances_
sklearn.ensemble._forest.RandomForestRegressor.__init__
sklearn.ensemble._forest.RandomForestRegressor.feature_importances_
sklearn.ensemble._forest.RandomTreesEmbedding.feature_importances_
sklearn.ensemble._gb.BaseGradientBoosting.loss_
sklearn.ensemble._gb.GradientBoostingClassifier.feature_importances_
sklearn.ensemble._gb.GradientBoostingRegressor.feature_importances_
sklearn.ensemble._gb_losses
Expand Down Expand Up @@ -1912,8 +1899,6 @@ sklearn.linear_model._coordinate_descent.MultiTaskElasticNet.sparse_coef_
sklearn.linear_model._coordinate_descent.MultiTaskElasticNetCV.path
sklearn.linear_model._coordinate_descent.MultiTaskLasso.sparse_coef_
sklearn.linear_model._coordinate_descent.MultiTaskLassoCV.path
sklearn.linear_model._glm._GeneralizedLinearRegressor.family
sklearn.linear_model._glm.glm._GeneralizedLinearRegressor.family
sklearn.linear_model._least_angle.Lars.__init__
sklearn.linear_model._least_angle.LarsCV.__init__
sklearn.linear_model._least_angle.LassoLars.__init__
Expand Down Expand Up @@ -2158,17 +2143,14 @@ sklearn.svm.NuSVC.coef_
sklearn.svm.NuSVC.n_support_
sklearn.svm.NuSVC.probA_
sklearn.svm.NuSVC.probB_
sklearn.svm.NuSVR.class_weight_
sklearn.svm.NuSVR.coef_
sklearn.svm.NuSVR.n_support_
sklearn.svm.OneClassSVM.class_weight_
sklearn.svm.OneClassSVM.coef_
sklearn.svm.OneClassSVM.n_support_
sklearn.svm.SVC.coef_
sklearn.svm.SVC.n_support_
sklearn.svm.SVC.probA_
sklearn.svm.SVC.probB_
sklearn.svm.SVR.class_weight_
sklearn.svm.SVR.coef_
sklearn.svm.SVR.n_support_
sklearn.svm._base.BaseLibSVM.n_support_
Expand All @@ -2178,17 +2160,14 @@ sklearn.svm._classes.NuSVC.coef_
sklearn.svm._classes.NuSVC.n_support_
sklearn.svm._classes.NuSVC.probA_
sklearn.svm._classes.NuSVC.probB_
sklearn.svm._classes.NuSVR.class_weight_
sklearn.svm._classes.NuSVR.coef_
sklearn.svm._classes.NuSVR.n_support_
sklearn.svm._classes.OneClassSVM.class_weight_
sklearn.svm._classes.OneClassSVM.coef_
sklearn.svm._classes.OneClassSVM.n_support_
sklearn.svm._classes.SVC.coef_
sklearn.svm._classes.SVC.n_support_
sklearn.svm._classes.SVC.probA_
sklearn.svm._classes.SVC.probB_
sklearn.svm._classes.SVR.class_weight_
sklearn.svm._classes.SVR.coef_
sklearn.svm._classes.SVR.n_support_
sklearn.tests.random_seed
Expand Down
Loading