Skip to content

Commit e92ff24

Browse files
committed
Disallow blanket ignores and remove unused noqa
1 parent 4cb0e74 commit e92ff24

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+183
-350
lines changed

pyproject.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,13 @@ target-version = "py39"
5656
extend-select = [
5757
"FA", # flake8-future-annotations
5858
"I", # isort
59+
"PGH", # pygrep-hooks
60+
"PGH", # pygrep-hooks and blanket-noqa
61+
"PIE790", # unnecessary-placeholder
5962
"PYI", # flake8-pyi
63+
"RUF", # Ruff-specific and unused-noqa
6064
"UP", # pyupgrade
6165
"W", # pycodestyle Warning
62-
"PIE790", # unnecessary-placeholder
6366
]
6467
ignore = [
6568
###
@@ -82,6 +85,11 @@ ignore = [
8285

8386
[tool.ruff.lint.per-file-ignores]
8487
"*.pyi" = [
88+
# Ruff 0.8.0 added sorting of __all__ and __slots_.
89+
# There is no consensus in typeshed on whether they want to apply this to stubs, so keeping the status quo.
90+
# See https://github.com/python/typeshed/pull/13108
91+
"RUF022", # `__all__` is not sorted
92+
"RUF023", # `{}.__slots__` is not sorted
8593
###
8694
# Rules that are out of the control of stub authors:
8795
###

stubs/matplotlib/backends/backend_qt.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class FigureCanvasQT(QtWidgets.QWidget, FigureCanvasBase):
4747
def keyPressEvent(self, event) -> None: ...
4848
def keyReleaseEvent(self, event) -> None: ...
4949
def resizeEvent(self, event) -> None: ...
50-
def sizeHint(self) -> QtCore.QSize: ... # type: ignore
51-
def minumumSizeHint(self) -> QtCore.QSize: ... # type: ignore
50+
def sizeHint(self) -> QtCore.QSize: ... # type: ignore[name-defined]
51+
def minumumSizeHint(self) -> QtCore.QSize: ... # type: ignore[name-defined]
5252
def flush_events(self) -> None: ...
5353
def start_event_loop(self, timeout=...) -> None: ...
5454
def stop_event_loop(self, event=...) -> None: ...
@@ -58,7 +58,7 @@ class FigureCanvasQT(QtWidgets.QWidget, FigureCanvasBase):
5858
def drawRectangle(self, rect) -> None: ...
5959

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

6464
class FigureManagerQT(FigureManagerBase):
@@ -71,7 +71,7 @@ class FigureManagerQT(FigureManagerBase):
7171
def set_window_title(self, title) -> None: ...
7272

7373
class NavigationToolbar2QT(NavigationToolbar2, QtWidgets.QToolBar):
74-
message: QtCore.Signal = ... # type: ignore
74+
message: QtCore.Signal = ... # type: ignore[name-defined]
7575
toolitems: list = ...
7676
def __init__(self, canvas, parent=..., coordinates=...) -> None: ...
7777
def edit_parameters(self) -> None: ...

stubs/networkx/algorithms/approximation/kcomponents.pyi

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
import itertools
2-
from collections import defaultdict
31
from collections.abc import Mapping
42
from functools import cached_property
53

64
from ...classes.graph import Graph
7-
from ...exception import NetworkXError
8-
from ...utils import not_implemented_for
9-
from . import local_node_connectivity
105

116
__all__ = ["k_components"]
127

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

1813
def single_edge_dict(self): ...
1914

20-
edge_attr_dict_factory = single_edge_dict # type: ignore
15+
edge_attr_dict_factory = single_edge_dict
2116

2217
def __getitem__(self, n) -> Mapping: ...
2318
def neighbors(self, n): ...

stubs/networkx/classes/digraph.pyi

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
from copy import deepcopy
21
from functools import cached_property
32

4-
import networkx.convert as convert
5-
6-
from ..classes.coreviews import AdjacencyView
73
from ..classes.graph import Graph
8-
from ..classes.reportviews import DiDegreeView, InDegreeView, InEdgeView, OutDegreeView, OutEdgeView
9-
from ..exception import NetworkXError
4+
from ..classes.reportviews import DiDegreeView, InEdgeView, OutEdgeView
105

116
__all__ = ["DiGraph"]
127

@@ -18,8 +13,8 @@ class _CachedPropertyResetterPred:
1813

1914
class DiGraph(Graph):
2015
graph = ...
21-
_adj = ... # type: ignore
22-
_succ = ... # type: ignore
16+
_adj = ...
17+
_succ = ...
2318
_pred = ...
2419

2520
def __init__(self, incoming_graph_data=None, **attr): ...

stubs/networkx/utils/decorators.pyi

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
1-
import bz2
2-
import collections
3-
import gzip
4-
import inspect
5-
import itertools
6-
import re
7-
from collections import defaultdict
81
from collections.abc import Sequence
9-
from contextlib import contextmanager
10-
from os.path import splitext
11-
from pathlib import Path
122
from typing import Callable
133

14-
from ..classes.graph import Graph
15-
from ..utils import create_py_random_state, create_random_state
16-
174
__all__ = [
185
"not_implemented_for",
196
"open_file",
@@ -30,7 +17,7 @@ def not_implemented_for(*graph_types): ...
3017
# To handle new extensions, define a function accepting a `path` and `mode`.
3118
# Then add the extension to _dispatch_dict.
3219
fopeners: dict = ...
33-
_dispatch_dict = ... # type: ignore
20+
_dispatch_dict = ...
3421

3522
def open_file(path_arg: str | int, mode: str = "r"): ...
3623
def nodes_or_number(which_args: str | int | Sequence[str]): ...

stubs/skimage/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from ._shared import lazy as lazy
2-
from ._shared.tester import PytestTester as PytestTester # noqa
2+
from ._shared.tester import PytestTester as PytestTester
33
from ._shared.version_requirements import ensure_python_version as ensure_python_version
44

55
__version__: str = ...

stubs/skimage/data/_registry.pyi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# flake8: noqa
2-
31
# This minimal dataset was available as part of
42
# scikit-image 0.15 and will be retained until
53
# further notice.
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
# This code is adapted for a large part from the astropy openmp helpers, which
2-
# can be found at: https://github.com/astropy/extension-helpers/blob/master/extension_helpers/_openmp_helpers.py # noqa
3-
41
def get_openmp_flag(compiler): ...
52
def check_openmp_support(): ...

stubs/sklearn/decomposition/_dict_learning.pyi

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,7 @@ from numpy.random import RandomState
66

77
from .._typing import ArrayLike, Float, Int, MatrixLike
88
from ..base import BaseEstimator, ClassNamePrefixFeaturesOutMixin, TransformerMixin
9-
from ..utils import (
10-
deprecated,
11-
)
129

13-
# Author: Vlad Niculae, Gael Varoquaux, Alexandre Gramfort
14-
# License: BSD 3 clause
15-
16-
# XXX : could be moved to the linear_model module
1710
def sparse_encode(
1811
X: ArrayLike,
1912
dictionary: MatrixLike,
@@ -180,15 +173,6 @@ class MiniBatchDictionaryLearning(_BaseSparseCoding, BaseEstimator):
180173
tol: Float = 1e-3,
181174
max_no_improvement: Int = 10,
182175
) -> None: ...
183-
@deprecated("The attribute `iter_offset_` is deprecated in 1.1 and will be removed in 1.3.") # type: ignore
184-
@property
185-
def iter_offset_(self) -> int: ...
186-
@deprecated("The attribute `random_state_` is deprecated in 1.1 and will be removed in 1.3.") # type: ignore
187-
@property
188-
def random_state_(self) -> RandomState: ...
189-
@deprecated("The attribute `inner_stats_` is deprecated in 1.1 and will be removed in 1.3.") # type: ignore
190-
@property
191-
def inner_stats_(self) -> tuple[ndarray, ndarray]: ...
192176
def fit(self, X: MatrixLike, y: Any = None) -> Self: ...
193177
def partial_fit(
194178
self,

stubs/sklearn/decomposition/_pca.pyi

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ from numpy import ndarray
55
from numpy.random import RandomState
66

77
from .._typing import Float, Int, MatrixLike
8-
from ..utils.deprecation import deprecated
98
from ._base import _BasePCA
109

1110
class PCA(_BasePCA):
@@ -35,14 +34,6 @@ class PCA(_BasePCA):
3534
power_iteration_normalizer: Literal["auto", "QR", "LU", "none"] = "auto",
3635
random_state: RandomState | None | Int = None,
3736
) -> None: ...
38-
39-
# TODO(1.4): remove in 1.4
40-
# mypy error: Decorated property not supported
41-
@deprecated( # type: ignore
42-
"Attribute `n_features_` was deprecated in version 1.2 and will be removed in 1.4. Use `n_features_in_` instead."
43-
)
44-
@property
45-
def n_features_(self) -> int: ...
4637
def fit(self, X: MatrixLike, y: Any = None) -> Self: ...
4738
def fit_transform(self, X: MatrixLike, y: Any = None) -> ndarray: ...
4839
def score_samples(self, X: MatrixLike) -> ndarray: ...

stubs/sklearn/ensemble/_base.pyi

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from typing_extensions import Self
55

66
from .._typing import Int
77
from ..base import BaseEstimator, MetaEstimatorMixin
8-
from ..utils import Bunch, deprecated
8+
from ..utils import Bunch
99
from ..utils.metaestimators import _BaseComposition
1010

1111
class BaseEnsemble(MetaEstimatorMixin, BaseEstimator, metaclass=ABCMeta):
@@ -23,18 +23,6 @@ class BaseEnsemble(MetaEstimatorMixin, BaseEstimator, metaclass=ABCMeta):
2323
estimator_params: Sequence[str] = ...,
2424
base_estimator: Any = "deprecated",
2525
) -> None: ...
26-
27-
# TODO(1.4): remove
28-
# mypy error: Decorated property not supported
29-
@deprecated( # type: ignore
30-
"Attribute `base_estimator_` was deprecated in version 1.2 and will be removed in 1.4. Use `estimator_` instead."
31-
)
32-
@property
33-
def base_estimator_(self) -> BaseEstimator: ...
34-
35-
# TODO(1.4): remove
36-
@property
37-
def estimator_(self) -> BaseEstimator: ...
3826
def __len__(self) -> int: ...
3927
def __getitem__(self, index): ...
4028
def __iter__(self): ...

stubs/sklearn/ensemble/_gb.pyi

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ from numpy.random import RandomState
88

99
from .._typing import ArrayLike, Float, Int, MatrixLike
1010
from ..base import BaseEstimator, ClassifierMixin, RegressorMixin
11-
from ..utils import deprecated
1211
from ._base import BaseEnsemble
1312
from ._gb_losses import LossFunction
1413

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

60-
# TODO(1.3): Remove
61-
# mypy error: Decorated property not supported
62-
@deprecated("Attribute `loss_` was deprecated in version 1.1 and will be removed in 1.3.") # type: ignore
63-
def loss_(self): ...
64-
6559
class GradientBoostingClassifier(ClassifierMixin, BaseGradientBoosting):
6660
max_features_: int = ...
6761
n_classes_: int = ...

stubs/sklearn/linear_model/_glm/glm.pyi

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ from ..._loss.loss import (
88
)
99
from ..._typing import ArrayLike, Float, Int, MatrixLike
1010
from ...base import BaseEstimator, RegressorMixin
11-
from ...utils import deprecated
1211

1312
class _GeneralizedLinearRegressor(RegressorMixin, BaseEstimator):
1413
_base_loss: BaseLoss = ...
@@ -46,10 +45,6 @@ class _GeneralizedLinearRegressor(RegressorMixin, BaseEstimator):
4645
sample_weight: None | ArrayLike = None,
4746
) -> Float: ...
4847

49-
# TODO(1.3): remove
50-
@deprecated("Attribute `family` was deprecated in version 1.1 and will be removed in 1.3.") # type: ignore
51-
def family(self): ...
52-
5348
class PoissonRegressor(_GeneralizedLinearRegressor):
5449
n_iter_: int = ...
5550
feature_names_in_: ndarray = ...

stubs/sklearn/svm/_classes.pyi

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ from numpy.random import RandomState
88
from .._typing import ArrayLike, Float, Int, MatrixLike
99
from ..base import BaseEstimator, OutlierMixin, RegressorMixin
1010
from ..linear_model._base import LinearClassifierMixin, LinearModel, SparseCoefMixin
11-
from ..utils import deprecated
1211
from ._base import BaseLibSVM, BaseSVC
1312

1413
class LinearSVC(LinearClassifierMixin, SparseCoefMixin, BaseEstimator):
@@ -187,11 +186,6 @@ class SVR(RegressorMixin, BaseLibSVM):
187186
max_iter: Int = ...,
188187
) -> None: ...
189188

190-
# TODO(1.4): Remove
191-
@deprecated("Attribute `class_weight_` was deprecated in version 1.2 and will be removed in 1.4.") # type: ignore
192-
@property
193-
def class_weight_(self) -> ndarray: ...
194-
195189
class NuSVR(RegressorMixin, BaseLibSVM):
196190
support_vectors_: ndarray = ...
197191
support_: ndarray = ...
@@ -225,11 +219,6 @@ class NuSVR(RegressorMixin, BaseLibSVM):
225219
max_iter: Int = ...,
226220
) -> None: ...
227221

228-
# TODO(1.4): Remove
229-
@deprecated("Attribute `class_weight_` was deprecated in version 1.2 and will be removed in 1.4.") # type: ignore
230-
@property
231-
def class_weight_(self) -> ndarray: ...
232-
233222
class OneClassSVM(OutlierMixin, BaseLibSVM):
234223
support_vectors_: ndarray = ...
235224
support_: ndarray = ...
@@ -262,11 +251,6 @@ class OneClassSVM(OutlierMixin, BaseLibSVM):
262251
verbose: bool = False,
263252
max_iter: Int = ...,
264253
) -> None: ...
265-
266-
# TODO(1.4): Remove
267-
@deprecated("Attribute `class_weight_` was deprecated in version 1.2 and will be removed in 1.4.") # type: ignore
268-
@property
269-
def class_weight_(self) -> ndarray: ...
270254
def fit(
271255
self,
272256
X: MatrixLike | ArrayLike,

stubs/sklearn/utils/_estimator_html_repr.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ class _VisualBlock:
2121
dash_wrapped: bool = True,
2222
) -> None: ...
2323

24-
_STYLE = ... # noqa
24+
_STYLE = ...
2525

2626
def estimator_html_repr(estimator: BaseEstimator) -> str: ...

stubs/sklearn/utils/_pprint.pyi

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,4 @@ class _EstimatorPrettyPrinter(pprint.PrettyPrinter):
7979
) -> None: ...
8080
def format(self, object, context: dict[Any, Any] | dict[int, int], maxlevels, level: int) -> tuple[str, bool, bool]: ...
8181

82-
# Note: need to copy _dispatch to prevent instances of the builtin
83-
# PrettyPrinter class to call methods of _EstimatorPrettyPrinter (see issue
84-
# 12906)
85-
# mypy error: "Type[PrettyPrinter]" has no attribute "_dispatch"
86-
_dispatch = ... # type: ignore
82+
_dispatch = ...

stubs/sympy-stubs/assumptions/assume.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class AppliedPredicate(Boolean):
2424
def binary_symbols(self) -> set[Basic] | set[Any]: ...
2525

2626
class PredicateMeta(type):
27-
def __new__(cls, clsname, bases, dct) -> Self: # type: ignore
27+
def __new__(cls, clsname, bases, dct) -> Self: # pyright: ignore[reportGeneralTypeIssues]
2828
...
2929
@property
3030
def __doc__(cls): ...

stubs/sympy-stubs/core/function.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class UndefSageHelper:
7272
_undef_sage_helper = ...
7373

7474
class UndefinedFunction(FunctionClass):
75-
def __new__(cls, name, bases=..., __dict__=..., **kwargs) -> Self: # type: ignore
75+
def __new__(cls, name, bases=..., __dict__=..., **kwargs) -> Self: # pyright: ignore[reportGeneralTypeIssues]
7676
...
7777
def __instancecheck__(cls, instance) -> bool: ...
7878

stubs/sympy-stubs/core/kind.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ from typing_extensions import LiteralString, Self
44
from sympy.core.cache import cacheit
55

66
class KindMeta(type):
7-
def __new__(cls, clsname, bases, dct) -> Self: # type: ignore
7+
def __new__(cls, clsname, bases, dct) -> Self: # pyright: ignore[reportGeneralTypeIssues]
88
...
99

1010
class Kind(metaclass=KindMeta):

stubs/sympy-stubs/polys/agca/extensions.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ if sys.version_info >= (3, 10):
1111
else:
1212
NotImplementedType: TypeAlias = Any
1313

14-
class ExtensionElement(DomainElement, DefaultPrinting): # type: ignore
14+
class ExtensionElement(DomainElement, DefaultPrinting):
1515
__slots__ = ...
1616
def __init__(self, rep, ext) -> None: ...
1717
def parent(self) -> Any: ...
@@ -47,7 +47,7 @@ class ExtensionElement(DomainElement, DefaultPrinting): # type: ignore
4747

4848
ExtElem = ExtensionElement
4949

50-
class MonogenicFiniteExtension(Domain): # type: ignore
50+
class MonogenicFiniteExtension(Domain):
5151
is_FiniteExtension = ...
5252
dtype = ExtensionElement
5353
def __init__(self, mod) -> None: ...

stubs/sympy-stubs/polys/domains/finitefield.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from sympy.core.numbers import Integer
55
from sympy.polys.domains.field import Field
66
from sympy.polys.domains.simpledomain import SimpleDomain
77

8-
class FiniteField(Field, SimpleDomain): # type: ignore
8+
class FiniteField(Field, SimpleDomain):
99
rep = ...
1010
alias = ...
1111
is_FF = ...

stubs/sympy-stubs/polys/domains/gaussiandomains.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if sys.version_info >= (3, 10):
1212
else:
1313
NotImplementedType: TypeAlias = Any
1414

15-
class GaussianElement(DomainElement): # type: ignore
15+
class GaussianElement(DomainElement):
1616
base: Domain
1717
_parent: Domain
1818
__slots__ = ...

0 commit comments

Comments
 (0)