Skip to content

Commit 76ca370

Browse files
authored
Disallow blanket ignores and remove unused noqa (#382)
1 parent d4aa725 commit 76ca370

Some content is hidden

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

62 files changed

+183
-371
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: ...

0 commit comments

Comments
 (0)