Skip to content

Commit 75f759e

Browse files
Upgrade LibCST to support Python 3.12 (#7764)
## Summary We'll revert back to the crates.io release once it's up-to-date, but better to get this out now that Python 3.12 is released. ## Test Plan `cargo test`
1 parent 6b99f5e commit 75f759e

File tree

4 files changed

+49
-6
lines changed

4 files changed

+49
-6
lines changed

Cargo.lock

+2-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ unicode-width = "0.1.11"
5353
uuid = { version = "1.4.1", features = ["v4", "fast-rng", "macro-diagnostics", "js"] }
5454
wsl = { version = "0.1.0" }
5555

56-
# v1.0.1
57-
libcst = { version = "0.1.0", default-features = false }
56+
libcst = { git = "https://github.com/Instagram/LibCST.git", rev = "03179b55ebe7e916f1722e18e8f0b87c01616d1f", default-features = false }
5857

5958
[profile.release]
6059
lto = "fat"

crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM117.py

+13
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,16 @@ async def main():
121121
with c as c2:
122122
async with d as d2:
123123
f(b2, c2, d2)
124+
125+
# SIM117
126+
with A() as a:
127+
with B() as b:
128+
type ListOrSet[T] = list[T] | set[T]
129+
130+
class ClassA[T: str]:
131+
def method1(self) -> T:
132+
...
133+
134+
f" something { my_dict["key"] } something else "
135+
136+
f"foo {f"bar {x}"} baz"

crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM117_SIM117.py.snap

+33
Original file line numberDiff line numberDiff line change
@@ -284,4 +284,37 @@ SIM117.py:106:5: SIM117 Use a single `with` statement with multiple contexts ins
284284
|
285285
= help: Combine `with` statements
286286

287+
SIM117.py:126:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements
288+
|
289+
125 | # SIM117
290+
126 | / with A() as a:
291+
127 | | with B() as b:
292+
| |__________________^ SIM117
293+
128 | type ListOrSet[T] = list[T] | set[T]
294+
|
295+
= help: Combine `with` statements
296+
297+
Suggested fix
298+
123 123 | f(b2, c2, d2)
299+
124 124 |
300+
125 125 | # SIM117
301+
126 |-with A() as a:
302+
127 |- with B() as b:
303+
128 |- type ListOrSet[T] = list[T] | set[T]
304+
126 |+with A() as a, B() as b:
305+
127 |+ type ListOrSet[T] = list[T] | set[T]
306+
129 128 |
307+
130 |- class ClassA[T: str]:
308+
131 |- def method1(self) -> T:
309+
132 |- ...
310+
129 |+ class ClassA[T: str]:
311+
130 |+ def method1(self) -> T:
312+
131 |+ ...
313+
133 132 |
314+
134 |- f" something { my_dict["key"] } something else "
315+
133 |+ f" something { my_dict["key"] } something else "
316+
135 134 |
317+
136 |- f"foo {f"bar {x}"} baz"
318+
135 |+ f"foo {f"bar {x}"} baz"
319+
287320

0 commit comments

Comments
 (0)