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

0 commit comments

Comments
 (0)