Skip to content

Commit c21ac43

Browse files
committed
Apply flake8+pycodestyles autofixes
1 parent 9c5664c commit c21ac43

File tree

159 files changed

+308
-526
lines changed

Some content is hidden

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

159 files changed

+308
-526
lines changed

pyproject.toml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,19 @@ line-length = 130
2727
target-version = "py39"
2828

2929
[tool.ruff.lint]
30-
# TODO: Use extend-select instead to get base E and F rules that don't conflict with the formatter
31-
select = [
30+
extend-select = [
3231
"FA", # flake8-future-annotations
3332
"I", # isort
3433
"PYI", # flake8-pyi
34+
"W", # pycodestyle Warning
3535
]
3636
ignore = [
3737
###
3838
# Rules we don't want or don't agree with
3939
###
40+
# Used for direct, non-subclass type comparison, for example: `type(val) is str`
41+
# see https://github.com/astral-sh/ruff/issues/6465
42+
"E721", # Do not compare types, use `isinstance()`
4043
# Typeshed doesn't want complex or non-literal defaults, or long strings, for maintenance and testing reasons.
4144
# This doesn't affect us, let's have more complete stubs.
4245
"PYI011",
@@ -46,6 +49,11 @@ ignore = [
4649
# TODO: Handle in its own PR
4750
"PYI021", # https://github.com/microsoft/python-type-stubs/pull/343
4851

52+
# TODO: Fixing these would change which symbols are even visible for Pylance.
53+
# Which may negatively affect users, especially if the symbol wasn't meant to be re-exported.
54+
# Manually evaluate each violation.
55+
"F401",
56+
4957
# TODO: Investigate and fix or configure
5058
"PYI001",
5159
"PYI002",
@@ -56,6 +64,17 @@ ignore = [
5664
"PYI051", # Request for autofix: https://github.com/astral-sh/ruff/issues/14185
5765
"PYI052",
5866
]
67+
[tool.ruff.lint.per-file-ignores]
68+
"*.pyi" = [
69+
###
70+
# Rules that are out of the control of stub authors:
71+
###
72+
"E743", # Ambiguous function name; stubs must follow implementation
73+
"F403", # `from . import *` used; unable to detect undefined names
74+
# Stubs can sometimes re-export entire modules.
75+
# Issues with using a star-imported name will be caught by type-checkers.
76+
"F405", # may be undefined, or defined from star imports
77+
]
5978

6079
[tool.ruff.lint.isort]
6180
combine-as-imports = true

stubs/matplotlib/legend_handler.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from collections.abc import Sequence
2-
from typing import Callable, Sequence
2+
from typing import Callable
33

44
from .artist import Artist
55
from .container import BarContainer

stubs/matplotlib/pyplot.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import numpy as np
99
from matplotlib import rcParams as rcParams, style as style
1010
from matplotlib.contour import QuadContourSet
1111

12-
from . import rcParams
1312
from ._typing import *
1413
from .artist import Artist
1514
from .axes import Axes as Axes
@@ -778,7 +777,7 @@ def tick_params(axis: Literal["x", "y", "both"] = ..., **kwargs): ...
778777
def ticklabel_format(
779778
*,
780779
axis: Literal["x", "y", "both"] = ...,
781-
style: Literal["sci", "scientific", "plain"] = ...,
780+
style: Literal["sci", "scientific", "plain"] = ..., # noqa: F811
782781
scilimits=...,
783782
useOffset: bool | float = ...,
784783
useLocale: bool = ...,

stubs/matplotlib/widgets.pyi

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ import numpy as np
88
from matplotlib.axes._axes import Axes
99
from matplotlib.backend_bases import DrawEvent, Event, FigureCanvasBase, KeyEvent, MouseButton, MouseEvent
1010
from matplotlib.figure import Figure
11-
from matplotlib.lines import Line2D
12-
from matplotlib.patches import Ellipse, Rectangle
13-
from matplotlib.transforms import Affine2D
1411
from numpy import float64, ndarray
1512
from numpy.typing import ArrayLike
1613
from PIL.Image import Image

stubs/networkx/algorithms/approximation/kcomponents.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import itertools
22
from collections import defaultdict
33
from collections.abc import Mapping
44
from functools import cached_property
5-
from typing import Mapping
65

76
from ...classes.graph import Graph
87
from ...exception import NetworkXError
Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
1-
from .asyn_fluid import asyn_fluidc as asyn_fluidc
2-
from .centrality import girvan_newman as girvan_newman
3-
from .community_utils import is_partition as is_partition
4-
from .kclique import k_clique_communities as k_clique_communities
5-
from .kernighan_lin import kernighan_lin_bisection as kernighan_lin_bisection
6-
from .label_propagation import (
7-
asyn_lpa_communities as asyn_lpa_communities,
8-
asyn_lpa_communities as label_propagation_communities,
9-
label_propagation_communities as label_propagation_communities,
10-
)
11-
from .louvain import louvain_communities as louvain_communities, louvain_partitions as louvain_partitions
12-
from .lukes import lukes_partitioning as lukes_partitioning
13-
from .modularity_max import (
14-
greedy_modularity_communities as greedy_modularity_communities,
15-
naive_greedy_modularity_communities as naive_greedy_modularity_communities,
16-
)
17-
from .quality import (
18-
coverage as coverage,
19-
modularity as modularity,
20-
partition_quality as partition_quality,
21-
performance as performance,
22-
)
1+
from networkx.algorithms.community.asyn_fluid import *
2+
from networkx.algorithms.community.centrality import *
3+
from networkx.algorithms.community.community_utils import *
4+
from networkx.algorithms.community.divisive import *
5+
from networkx.algorithms.community.kclique import *
6+
from networkx.algorithms.community.kernighan_lin import *
7+
from networkx.algorithms.community.label_propagation import *
8+
from networkx.algorithms.community.louvain import *
9+
from networkx.algorithms.community.lukes import *
10+
from networkx.algorithms.community.modularity_max import *
11+
from networkx.algorithms.community.quality import *

stubs/networkx/algorithms/connectivity/connectivity.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ from typing import Mapping
66
# connectivity algorithms.
77
from ...algorithms.flow import boykov_kolmogorov, build_residual_network, dinitz, edmonds_karp, shortest_augmenting_path
88
from ...classes.graph import Graph
9+
from .utils import build_auxiliary_edge_connectivity, build_auxiliary_node_connectivity
910

1011
default_flow_func = ...
1112

12-
from .utils import build_auxiliary_edge_connectivity, build_auxiliary_node_connectivity
13-
1413
__all__ = [
1514
"average_node_connectivity",
1615
"local_node_connectivity",

stubs/networkx/algorithms/connectivity/cuts.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ import itertools
44
# cut algorithms.
55
from ...algorithms.flow import build_residual_network, edmonds_karp
66
from ...classes.graph import Graph
7+
from .utils import build_auxiliary_edge_connectivity, build_auxiliary_node_connectivity
78

89
default_flow_func = ...
910

10-
from .utils import build_auxiliary_edge_connectivity, build_auxiliary_node_connectivity
11-
1211
__all__ = [
1312
"minimum_st_node_cut",
1413
"minimum_node_cut",

stubs/networkx/algorithms/connectivity/disjoint_paths.pyi

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
# Define the default maximum flow function to use for the undelying
22
# maximum flow computations
3+
from itertools import filterfalse as _filterfalse
4+
35
from ...algorithms.flow import edmonds_karp, preflow_push, shortest_augmenting_path
46
from ...classes.graph import Graph
57
from ...exception import NetworkXNoPath
68

7-
default_flow_func = ...
8-
from itertools import filterfalse as _filterfalse
9-
109
# Functions to build auxiliary data structures.
1110
from .utils import build_auxiliary_edge_connectivity, build_auxiliary_node_connectivity
1211

12+
default_flow_func = ...
13+
1314
__all__ = ["edge_disjoint_paths", "node_disjoint_paths"]
1415

1516
def edge_disjoint_paths(

stubs/networkx/algorithms/tree/branchings.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ from operator import itemgetter
2424
from queue import PriorityQueue
2525
from typing import Literal
2626

27-
from ...algorithms.tree.branchings import ArborescenceIterator
2827
from ...classes.digraph import DiGraph
2928
from ...classes.graph import Graph
3029
from ...classes.multidigraph import MultiDiGraph

stubs/networkx/algorithms/tree/decomposition.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ from itertools import combinations
33
from networkx import Graph
44

55
from ...algorithms import chordal_graph_cliques, complete_to_chordal_graph, moral
6-
from ...classes.graph import Graph
76
from ...utils import not_implemented_for
87

98
__all__ = ["junction_tree"]

stubs/networkx/algorithms/tree/mst.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ from math import isnan
66
from operator import itemgetter
77
from queue import PriorityQueue
88

9-
from ...algorithms.tree.mst import SpanningTreeIterator
109
from ...classes.graph import Graph
1110
from ...utils import UnionFind, not_implemented_for, py_random_state
1211

stubs/networkx/classes/graph.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ from numpy.typing import ArrayLike
88

99
from ..classes.coreviews import AdjacencyView
1010
from ..classes.digraph import DiGraph
11-
from ..classes.graph import Graph
1211
from ..classes.reportviews import DegreeView, EdgeView, NodeView
1312
from ..exception import NetworkXError
1413

stubs/networkx/classes/graphviews.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ from networkx import DiGraph, Graph
44

55
from ..classes.coreviews import FilterAdjacency, FilterAtlas, FilterMultiAdjacency, UnionAdjacency, UnionMultiAdjacency
66
from ..classes.filters import no_filter
7-
from ..classes.graph import Graph
87
from ..exception import NetworkXError
98
from ..utils import not_implemented_for
109

stubs/networkx/classes/reportviews.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ from collections.abc import Mapping, Set as AbstractSet
22
from typing import Any
33

44
from ..classes.graph import Graph
5-
from ..classes.reportviews import NodeDataView
65

76
__all__ = [
87
"NodeView",

stubs/networkx/generators/classic.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import numbers
33
from collections.abc import Iterable
44

55
from ..classes import Graph
6-
from ..classes.graph import Graph
76
from ..exception import NetworkXError
87
from ..utils import nodes_or_number, pairwise
98

stubs/networkx/generators/triads.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ from networkx import DiGraph
44
# Copyright 2011 Reya Group <http://www.reyagroup.com>
55
# Copyright 2011 Alex Levenson <[email protected]>
66
# Copyright 2011 Diederik van Liere <[email protected]>
7-
from ..classes import DiGraph
87

98
__all__ = ["triad_graph"]
109

stubs/skimage/__init__.pyi

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
__version__: str = ...
2-
3-
submodules: list = ...
4-
51
from ._shared import lazy as lazy
62
from ._shared.tester import PytestTester as PytestTester # noqa
73
from ._shared.version_requirements import ensure_python_version as ensure_python_version
84

5+
__version__: str = ...
6+
submodules: list = ...
97
__getattr__ = ...
108
__lazy_dir__ = ...
119

stubs/skimage/future/graph/rag.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ from numpy.lib.stride_tricks import as_strided
77
from scipy import ndimage as ndi, sparse
88

99
from ..._shared.version_requirements import require
10-
from .rag import RAG
1110

1211
def _edge_generator_from_csr(csr_matrix): ...
1312
def min_weight(graph: RAG, src: int, dst: int, n: int) -> Mapping: ...

stubs/skimage/measure/_regionprops.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ from scipy.spatial.distance import pdist
1212
from . import _moments
1313
from ._find_contours import find_contours
1414
from ._marching_cubes_lewiner import marching_cubes
15-
from ._regionprops import RegionProperties
1615
from ._regionprops_utils import euler_number, perimeter, perimeter_crofton
1716

1817
__all__ = ["regionprops", "euler_number", "perimeter", "perimeter_crofton"]

stubs/sklearn/base.pyi

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
import copy
2+
import inspect
3+
import platform
4+
import re
5+
import warnings
16
from collections import defaultdict as defaultdict
27
from typing import Any, ClassVar, Iterable, TypeVar
38

9+
import numpy as np
410
from numpy import ndarray
511

612
from ._config import get_config as get_config
@@ -16,14 +22,6 @@ BaseEstimator_Self = TypeVar("BaseEstimator_Self", bound=BaseEstimator)
1622
# Author: Gael Varoquaux <[email protected]>
1723
# License: BSD 3 clause
1824

19-
import copy
20-
import inspect
21-
import platform
22-
import re
23-
import warnings
24-
25-
import numpy as np
26-
2725
def clone(estimator: BaseEstimator | Iterable[BaseEstimator], *, safe: bool = True) -> Any: ...
2826

2927
class BaseEstimator:

stubs/sklearn/calibration.pyi

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import warnings
12
from functools import partial as partial
23
from inspect import signature as signature
34
from math import log as log
45
from numbers import Integral as Integral
56
from typing import ClassVar, Iterable, Literal, TypeVar
67

8+
import numpy as np
79
from matplotlib.artist import Artist
810
from matplotlib.axes import Axes
911
from matplotlib.figure import Figure
@@ -33,10 +35,6 @@ from .utils.validation import check_consistent_length as check_consistent_length
3335
CalibratedClassifierCV_Self = TypeVar("CalibratedClassifierCV_Self", bound=CalibratedClassifierCV)
3436
_SigmoidCalibration_Self = TypeVar("_SigmoidCalibration_Self", bound=_SigmoidCalibration)
3537

36-
import warnings
37-
38-
import numpy as np
39-
4038
class CalibratedClassifierCV(ClassifierMixin, MetaEstimatorMixin, BaseEstimator):
4139
calibrated_classifiers_: list = ...
4240
feature_names_in_: ndarray = ...

stubs/sklearn/cluster/_affinity_propagation.pyi

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import warnings
12
from numbers import Integral as Integral, Real as Real
23
from typing import Any, ClassVar, Literal, TypeVar
34

5+
import numpy as np
46
from numpy import ndarray
57
from numpy.random import RandomState
68

@@ -15,10 +17,6 @@ from ..utils.validation import check_is_fitted as check_is_fitted
1517

1618
AffinityPropagation_Self = TypeVar("AffinityPropagation_Self", bound=AffinityPropagation)
1719

18-
import warnings
19-
20-
import numpy as np
21-
2220
###############################################################################
2321
# Public API
2422

stubs/sklearn/cluster/_agglomerative.pyi

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import warnings
12
from heapq import heapify as heapify, heappop as heappop, heappush as heappush, heappushpop as heappushpop
23
from numbers import Integral as Integral, Real as Real
34
from typing import Any, Callable, ClassVar, Literal, Set, TypeVar
45

6+
import numpy as np
57
from joblib import Memory
68
from numpy import ndarray
79
from scipy import sparse as sparse
@@ -22,10 +24,6 @@ from ._feature_agglomeration import AgglomerationTransform
2224
FeatureAgglomeration_Self = TypeVar("FeatureAgglomeration_Self", bound=FeatureAgglomeration)
2325
AgglomerativeClustering_Self = TypeVar("AgglomerativeClustering_Self", bound=AgglomerativeClustering)
2426

25-
import warnings
26-
27-
import numpy as np
28-
2927
###############################################################################
3028
# Hierarchical tree building functions
3129

stubs/sklearn/cluster/_bicluster.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ from abc import ABCMeta, abstractmethod
22
from numbers import Integral as Integral
33
from typing import Any, ClassVar, Literal, TypeVar
44

5+
import numpy as np
56
from numpy import ndarray
67
from numpy.random import RandomState
78
from scipy.linalg import norm as norm
@@ -22,8 +23,6 @@ from . import KMeans as KMeans, MiniBatchKMeans as MiniBatchKMeans
2223

2324
BaseSpectral_Self = TypeVar("BaseSpectral_Self", bound=BaseSpectral)
2425

25-
import numpy as np
26-
2726
__all__ = ["SpectralCoclustering", "SpectralBiclustering"]
2827

2928
class BaseSpectral(BiclusterMixin, BaseEstimator, metaclass=ABCMeta):

stubs/sklearn/cluster/_birch.pyi

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import warnings
12
from math import sqrt as sqrt
23
from numbers import Integral as Integral, Real as Real
34
from typing import Any, ClassVar, TypeVar
45

6+
import numpy as np
57
from numpy import ndarray
68
from scipy import sparse as sparse
79
from scipy.sparse import spmatrix
@@ -24,10 +26,6 @@ Birch_Self = TypeVar("Birch_Self", bound=Birch)
2426
# Joel Nothman <[email protected]>
2527
# License: BSD 3 clause
2628

27-
import warnings
28-
29-
import numpy as np
30-
3129
class _CFNode:
3230
squared_norm_: ndarray = ...
3331
centroids_: ndarray = ...

0 commit comments

Comments
 (0)