Skip to content

Commit 6be1479

Browse files
authored
Apply flake8+pycodestyles autofixes (#342)
1 parent 809be63 commit 6be1479

File tree

152 files changed

+291
-508
lines changed

Some content is hidden

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

152 files changed

+291
-508
lines changed

pyproject.toml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,33 @@ 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
3534
"UP", # pyupgrade
35+
"W", # pycodestyle Warning
3636
]
3737
ignore = [
3838
###
3939
# Rules we don't want or don't agree with
4040
###
4141

42+
# Used for direct, non-subclass type comparison, for example: `type(val) is str`
43+
# see https://github.com/astral-sh/ruff/issues/6465
44+
"E721", # Do not compare types, use `isinstance()`
45+
4246
# Typeshed doesn't want complex or non-literal defaults, or long strings, for maintenance and testing reasons.
4347
# This doesn't affect us, let's have more complete stubs.
4448
"PYI011",
4549
"PYI014",
4650
"PYI053",
4751

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+
4857
# TODO: Investigate and fix or configure
4958
"PYI001",
5059
"PYI002",
@@ -55,8 +64,18 @@ ignore = [
5564
"PYI051", # Request for autofix: https://github.com/astral-sh/ruff/issues/14185
5665
"PYI052",
5766
]
58-
5967
[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+
]
78+
6079
# We keep docstrings in sklearn
6180
"stubs/sklearn/**" = ["PYI021"]
6281

stubs/matplotlib/pyplot.pyi

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

14-
from . import rcParams
1514
from ._typing import *
1615
from .artist import Artist
1716
from .axes import Axes as Axes
@@ -780,7 +779,7 @@ def tick_params(axis: Literal["x", "y", "both"] = ..., **kwargs): ...
780779
def ticklabel_format(
781780
*,
782781
axis: Literal["x", "y", "both"] = ...,
783-
style: Literal["sci", "scientific", "plain"] = ...,
782+
style: Literal["sci", "scientific", "plain"] = ..., # noqa: F811
784783
scilimits=...,
785784
useOffset: bool | float = ...,
786785
useLocale: bool = ...,

stubs/matplotlib/widgets.pyi

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ import numpy as np
99
from matplotlib.axes._axes import Axes
1010
from matplotlib.backend_bases import DrawEvent, Event, FigureCanvasBase, KeyEvent, MouseButton, MouseEvent
1111
from matplotlib.figure import Figure
12-
from matplotlib.lines import Line2D
13-
from matplotlib.patches import Ellipse, Rectangle
14-
from matplotlib.transforms import Affine2D
1512
from numpy import float64, ndarray
1613
from numpy.typing import ArrayLike
1714
from PIL.Image import Image
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 operator import itemgetter
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

0 commit comments

Comments
 (0)