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 1 commit
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
16 changes: 0 additions & 16 deletions stubs/sklearn/svm/_classes.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, OutlierMixin, RegressorMixin
from ..linear_model._base import LinearClassifierMixin, LinearModel, SparseCoefMixin
from ..utils import deprecated
from ._base import BaseLibSVM, BaseSVC

class LinearSVC(LinearClassifierMixin, SparseCoefMixin, BaseEstimator):
Expand Down Expand Up @@ -187,11 +186,6 @@ class SVR(RegressorMixin, BaseLibSVM):
max_iter: Int = ...,
) -> None: ...

# TODO(1.4): Remove
@deprecated("Attribute `class_weight_` was deprecated in version 1.2 and will be removed in 1.4.") # type: ignore
@property
def class_weight_(self) -> ndarray: ...

class NuSVR(RegressorMixin, BaseLibSVM):
support_vectors_: ndarray = ...
support_: ndarray = ...
Expand Down Expand Up @@ -225,11 +219,6 @@ class NuSVR(RegressorMixin, BaseLibSVM):
max_iter: Int = ...,
) -> None: ...

# TODO(1.4): Remove
@deprecated("Attribute `class_weight_` was deprecated in version 1.2 and will be removed in 1.4.") # type: ignore
@property
def class_weight_(self) -> ndarray: ...

class OneClassSVM(OutlierMixin, BaseLibSVM):
support_vectors_: ndarray = ...
support_: ndarray = ...
Expand Down Expand Up @@ -262,11 +251,6 @@ class OneClassSVM(OutlierMixin, BaseLibSVM):
verbose: bool = False,
max_iter: Int = ...,
) -> None: ...

# TODO(1.4): Remove
@deprecated("Attribute `class_weight_` was deprecated in version 1.2 and will be removed in 1.4.") # type: ignore
@property
def class_weight_(self) -> ndarray: ...
def fit(
self,
X: MatrixLike | ArrayLike,
Expand Down
2 changes: 1 addition & 1 deletion stubs/sklearn/utils/_estimator_html_repr.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ class _VisualBlock:
dash_wrapped: bool = True,
) -> None: ...

_STYLE = ... # noqa
_STYLE = ...

def estimator_html_repr(estimator: BaseEstimator) -> str: ...
6 changes: 1 addition & 5 deletions stubs/sklearn/utils/_pprint.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,4 @@ class _EstimatorPrettyPrinter(pprint.PrettyPrinter):
) -> None: ...
def format(self, object, context: dict[Any, Any] | dict[int, int], maxlevels, level: int) -> tuple[str, bool, bool]: ...

# Note: need to copy _dispatch to prevent instances of the builtin
# PrettyPrinter class to call methods of _EstimatorPrettyPrinter (see issue
# 12906)
# mypy error: "Type[PrettyPrinter]" has no attribute "_dispatch"
_dispatch = ... # type: ignore
_dispatch = ...
2 changes: 1 addition & 1 deletion stubs/sympy-stubs/assumptions/assume.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class AppliedPredicate(Boolean):
def binary_symbols(self) -> set[Basic] | set[Any]: ...

class PredicateMeta(type):
def __new__(cls, clsname, bases, dct) -> Self: # type: ignore
def __new__(cls, clsname, bases, dct) -> Self: # pyright: ignore[reportGeneralTypeIssues]
...
@property
def __doc__(cls): ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/sympy-stubs/core/function.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class UndefSageHelper:
_undef_sage_helper = ...

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

Expand Down
2 changes: 1 addition & 1 deletion stubs/sympy-stubs/core/kind.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ from typing_extensions import LiteralString, Self
from sympy.core.cache import cacheit

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

class Kind(metaclass=KindMeta):
Expand Down
4 changes: 2 additions & 2 deletions stubs/sympy-stubs/polys/agca/extensions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if sys.version_info >= (3, 10):
else:
NotImplementedType: TypeAlias = Any

class ExtensionElement(DomainElement, DefaultPrinting): # type: ignore
class ExtensionElement(DomainElement, DefaultPrinting):
__slots__ = ...
def __init__(self, rep, ext) -> None: ...
def parent(self) -> Any: ...
Expand Down Expand Up @@ -47,7 +47,7 @@ class ExtensionElement(DomainElement, DefaultPrinting): # type: ignore

ExtElem = ExtensionElement

class MonogenicFiniteExtension(Domain): # type: ignore
class MonogenicFiniteExtension(Domain):
is_FiniteExtension = ...
dtype = ExtensionElement
def __init__(self, mod) -> None: ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/sympy-stubs/polys/domains/finitefield.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from sympy.core.numbers import Integer
from sympy.polys.domains.field import Field
from sympy.polys.domains.simpledomain import SimpleDomain

class FiniteField(Field, SimpleDomain): # type: ignore
class FiniteField(Field, SimpleDomain):
rep = ...
alias = ...
is_FF = ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/sympy-stubs/polys/domains/gaussiandomains.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if sys.version_info >= (3, 10):
else:
NotImplementedType: TypeAlias = Any

class GaussianElement(DomainElement): # type: ignore
class GaussianElement(DomainElement):
base: Domain
_parent: Domain
__slots__ = ...
Expand Down
Loading
Loading