Skip to content

Commit 558e8de

Browse files
dependabot[bot]IvanIsCodingmtreinish
authored
Bump ruff from 0.14.3 to 0.15.7 (#1566)
* Remove retworkx and Python 3.9 support * Add release notes for Python 3.9 EoL * Add retworkx removal release note * Drop 3.9 support in pyproject.toml and uv * Bump other 39 -> 310 related things * use 3.14 not 3.14-dev * Move note to upgrade * Upgrade packages to support 3.14 * Allowlist missing __all__ for mypy * Add 3.14 to workflow * Add release note * Use Python 3.12 for release * Skip Python 3.9 * Skip 3.14 free-threaded build * Bump nox as well * Use ruff * Use ruff in CI * Use macos-15-intel for tests * Update wheels.yml to use macos-15-intel * Apply suggestions from code review Co-authored-by: Matthew Treinish <mtreinish@kortar.org> * Reflect cibuildwheel in uv * Minimize uv lock diff * Bump black from 25.9.0 to 26.3.1 Bumps [black](https://github.com/psf/black) from 25.9.0 to 26.3.1. - [Release notes](https://github.com/psf/black/releases) - [Changelog](https://github.com/psf/black/blob/main/CHANGES.md) - [Commits](psf/black@25.9.0...26.3.1) --- updated-dependencies: - dependency-name: black dependency-version: 26.3.1 dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@github.com> * Revert "Bump black from 25.9.0 to 26.3.1" This reverts commit f7df88c. * uv lock for ruff 0.15.7 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Ivan Carvalho <ivancarvalho@gatech.edu> Co-authored-by: Ivan Carvalho <8753214+IvanIsCoding@users.noreply.github.com> Co-authored-by: Matthew Treinish <mtreinish@kortar.org> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 98efff2 commit 558e8de

19 files changed

+66
-135
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ jobs:
3737
run: cargo fmt --all -- --check
3838
- name: Clippy
3939
run: cargo clippy --workspace --all-targets -- -D warnings
40-
- name: Black Codestyle Format
41-
run: black --check --diff rustworkx tests
40+
- name: Ruff Codestyle Format
41+
run: ruff format --check --diff rustworkx tests
4242
- name: Python Lint
4343
run: ruff check rustworkx setup.py tests
4444
- name: Check stray release notes

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ cargo clippy --workspace --all-targets -- -D warnings
285285
286286
Python is used primarily for tests and some small pieces of packaging
287287
and namespace configuration code in the actual library.
288-
[black](https://github.com/psf/black) and [flake8](https://flake8.pycqa.org/en/latest/) are used to enforce consistent
288+
[ruff](https://github.com/astral-sh/ruff) is used to enforce consistent
289289
style in the python code in the repository. You can run them via Nox using:
290290
291291
```bash
@@ -295,7 +295,7 @@ nox -e lint
295295
This will also run `cargo fmt` in check mode to ensure that you ran `cargo fmt`
296296
and will fail if the Rust code doesn't conform to the style rules.
297297
298-
If black returns a code formatting error you can run `nox -e black` to automatically
298+
If ruff returns a code formatting error you can run `nox -e format` to automatically
299299
update the code formatting to conform to the style.
300300
301301
### Building documentation

noxfile.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_with_version(session):
3131

3232
@nox.session(python=["3"])
3333
def lint(session):
34-
black(session)
34+
format(session)
3535
typos(session)
3636
session.install(*lint_deps)
3737
session.run("ruff", "check", "rustworkx", "setup.py")
@@ -71,10 +71,15 @@ def docs_clean(session):
7171
session.chdir("docs")
7272
session.run("rm", "-rf", "build", "source/apiref", external=True)
7373

74+
@nox.session(python=["3"])
75+
def format(session):
76+
session.install(*[d for d in lint_deps if "ruff" in d])
77+
session.run("ruff", "format", "rustworkx", "tests", *session.posargs)
78+
7479
@nox.session(python=["3"])
7580
def black(session):
76-
session.install(*[d for d in lint_deps if "black" in d])
77-
session.run("black", "rustworkx", "tests", *session.posargs)
81+
# Legacy black formatting session is aliased
82+
format(session)
7883

7984
@nox.session(python=["3"])
8085
def typos(session):

pyproject.toml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ test = [
7676
"stestr>=4.1",
7777
]
7878
lint = [
79-
"black~=25.9",
80-
"ruff==0.14.3",
79+
"ruff==0.15.7",
8180
"setuptools-rust",
8281
"typos~=1.39",
8382
]
@@ -103,12 +102,8 @@ releaseinfra = [
103102
"cibuildwheel==3.3.0; python_version >= '3.11'",
104103
]
105104

106-
[tool.black]
107-
line-length = 100
108-
target-version = ['py310', 'py311', 'py312', 'py313', 'py314']
109-
110105
[tool.ruff]
111-
line-length = 105 # more lenient than black due to long function signatures
106+
line-length = 100
112107
src = ["rustworkx", "setup.py", "tests"]
113108
lint.select = [
114109
"E", # pycodestyle
@@ -124,6 +119,14 @@ extend-exclude = ["doc"]
124119
"rustworkx/__init__.py" = ["F405", "F403"]
125120
"*.pyi" = ["F403", "F405", "PYI001", "PYI002"]
126121

122+
[tool.ruff.lint.pycodestyle]
123+
max-line-length = 105 # lint has a larger limit than the formatter because of long signatures
124+
125+
[tool.ruff.format]
126+
quote-style = "double"
127+
indent-style = "space"
128+
docstring-code-format = true
129+
127130
[tool.typos.default]
128131
extend-ignore-words-re = [
129132
"[Ss]toer",

rustworkx/__init__.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,14 @@ class PyDAG(PyDiGraph):
8585
attribute to True. For example::
8686
8787
import rustworkx as rx
88+
8889
dag = rx.PyDAG()
8990
dag.check_cycle = True
9091
9192
or at object creation::
9293
9394
import rustworkx as rx
95+
9496
dag = rx.PyDAG(check_cycle=True)
9597
9698
With check_cycle set to true any calls to :meth:`PyDAG.add_edge` will
@@ -110,6 +112,7 @@ class PyDAG(PyDiGraph):
110112
For example::
111113
112114
import rustworkx as rx
115+
113116
dag = rx.PyDAG(multigraph=False)
114117
115118
This can only be set at ``PyDiGraph`` initialization and not adjusted after
@@ -303,7 +306,7 @@ def floyd_warshall(
303306
tells rustworkx/rust how to extract a numerical weight as a ``float``
304307
for edge object. Some simple examples are::
305308
306-
floyd_warshall(graph, weight_fn= lambda x: 1)
309+
floyd_warshall(graph, weight_fn=lambda x: 1)
307310
308311
to return a weight of 1 for all edges. Also::
309312
@@ -489,7 +492,7 @@ def all_pairs_dijkstra_shortest_paths(graph, edge_cost_fn):
489492
of node indices making the path. For example::
490493
491494
{
492-
0: {1: [0, 1], 2: [0, 1, 2]},
495+
0: {1: [0, 1], 2: [0, 1, 2]},
493496
1: {2: [1, 2]},
494497
2: {0: [2, 0]},
495498
}
@@ -669,8 +672,7 @@ def is_isomorphic(
669672
670673
graph_a = rustworkx.PyGraph()
671674
graph_b = rustworkx.PyGraph()
672-
rustworkx.is_isomorphic(graph_a, graph_b,
673-
lambda x, y: x == y)
675+
rustworkx.is_isomorphic(graph_a, graph_b, lambda x, y: x == y)
674676
675677
.. note::
676678
@@ -717,8 +719,7 @@ def is_isomorphic_node_match(first, second, matcher, id_order=True):
717719
718720
graph_a = rustworkx.PyDAG()
719721
graph_b = rustworkx.PyDAG()
720-
rustworkx.is_isomorphic_node_match(graph_a, graph_b,
721-
lambda x, y: x == y)
722+
rustworkx.is_isomorphic_node_match(graph_a, graph_b, lambda x, y: x == y)
722723
723724
.. note::
724725
@@ -768,8 +769,7 @@ def is_subgraph_isomorphic(
768769
769770
graph_a = rustworkx.PyGraph()
770771
graph_b = rustworkx.PyGraph()
771-
rustworkx.is_subgraph_isomorphic(graph_a, graph_b,
772-
lambda x, y: x == y)
772+
rustworkx.is_subgraph_isomorphic(graph_a, graph_b, lambda x, y: x == y)
773773
774774
775775
:param first: The first graph to compare. Can either be a
@@ -2018,7 +2018,7 @@ def all_pairs_bellman_ford_shortest_paths(graph, edge_cost_fn):
20182018
of node indices making the path. For example::
20192019
20202020
{
2021-
0: {1: [0, 1], 2: [0, 1, 2]},
2021+
0: {1: [0, 1], 2: [0, 1, 2]},
20222022
1: {2: [1, 2]},
20232023
2: {0: [2, 0]},
20242024
}

rustworkx/rustworkx.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ def layers(
375375
/,
376376
index_output: bool = ...,
377377
) -> list[list[_S]] | list[list[int]]: ...
378+
378379
@final
379380
class TopologicalSorter:
380381
def __init__(

rustworkx/visualization/matplotlib.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,23 +142,23 @@ def mpl_draw(graph, pos=None, ax=None, arrows=True, with_labels=False, **kwds):
142142
:param func labels: An optional callback function that will be passed a
143143
node payload and return a string label for the node. For example::
144144
145-
labels=str
145+
labels = str
146146
147147
could be used to just return a string cast of the node's data payload.
148148
Or something like::
149149
150-
labels=lambda node: node['label']
150+
labels = lambda node: node["label"]
151151
152152
could be used if the node payloads are dictionaries.
153153
:param func edge_labels: An optional callback function that will be passed
154154
an edge payload and return a string label for the edge. For example::
155155
156-
edge_labels=str
156+
edge_labels = str
157157
158158
could be used to just return a string cast of the edge's data payload.
159159
Or something like::
160160
161-
edge_labels=lambda edge: edge['label']
161+
edge_labels = lambda edge: edge["label"]
162162
163163
could be used if the edge payloads are dictionaries. If this is set
164164
edge labels will be drawn in the visualization.

tests/digraph/test_bfs_search.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ def tree_edge(self, edge):
5757

5858
def test_digraph_bfs_tree_edges_restricted(self):
5959
class TreeEdgesRecorderRestricted(rustworkx.visit.BFSVisitor):
60-
6160
prohibited = [(0, 2), (1, 2)]
6261

6362
def __init__(self):
@@ -75,7 +74,6 @@ def tree_edge(self, edge):
7574

7675
def test_digraph_bfs_goal_search_with_stop_search_exception(self):
7776
class GoalSearch(rustworkx.visit.BFSVisitor):
78-
7977
goal = 3
8078

8179
def __init__(self):
@@ -107,7 +105,6 @@ class StopIfGoalFound(Exception):
107105
pass
108106

109107
class GoalSearch(rustworkx.visit.BFSVisitor):
110-
111108
goal = 3
112109

113110
def __init__(self):

tests/digraph/test_dfs_search.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ def tree_edge(self, edge):
5757

5858
def test_digraph_dfs_tree_edges_restricted(self):
5959
class TreeEdgesRecorderRestricted(rustworkx.visit.DFSVisitor):
60-
6160
prohibited = [(0, 1), (5, 3)]
6261

6362
def __init__(self):
@@ -75,7 +74,6 @@ def tree_edge(self, edge):
7574

7675
def test_digraph_dfs_goal_search(self):
7776
class GoalSearch(rustworkx.visit.DFSVisitor):
78-
7977
goal = 3
8078

8179
def __init__(self):

tests/digraph/test_dijkstra_search.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ def edge_relaxed(self, edge):
7171

7272
def test_digraph_dijkstra_goal_search_with_stop_search_exception(self):
7373
class GoalSearch(rustworkx.visit.DijkstraVisitor):
74-
7574
goal = 3
7675

7776
def __init__(self):
@@ -107,7 +106,6 @@ class StopIfGoalFound(Exception):
107106
pass
108107

109108
class GoalSearch(rustworkx.visit.DijkstraVisitor):
110-
111109
goal = 3
112110

113111
def __init__(self):
@@ -143,7 +141,6 @@ def reconstruct_path(self):
143141

144142
def test_digraph_dijkstra_goal_search_with_prohibited_edges(self):
145143
class GoalSearch(rustworkx.visit.DijkstraVisitor):
146-
147144
goal = 3
148145
prohibited = [(5, 3)]
149146

0 commit comments

Comments
 (0)