Skip to content

Commit

Permalink
Upgrade LibCST to support Python 3.12 (#7764)
Browse files Browse the repository at this point in the history
## 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`
  • Loading branch information
charliermarsh authored Oct 2, 2023
1 parent 6b99f5e commit 75f759e
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 6 deletions.
6 changes: 2 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ unicode-width = "0.1.11"
uuid = { version = "1.4.1", features = ["v4", "fast-rng", "macro-diagnostics", "js"] }
wsl = { version = "0.1.0" }

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

[profile.release]
lto = "fat"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,16 @@ async def main():
with c as c2:
async with d as d2:
f(b2, c2, d2)

# SIM117
with A() as a:
with B() as b:
type ListOrSet[T] = list[T] | set[T]

class ClassA[T: str]:
def method1(self) -> T:
...

f" something { my_dict["key"] } something else "

f"foo {f"bar {x}"} baz"
Original file line number Diff line number Diff line change
Expand Up @@ -284,4 +284,37 @@ SIM117.py:106:5: SIM117 Use a single `with` statement with multiple contexts ins
|
= help: Combine `with` statements

SIM117.py:126:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements
|
125 | # SIM117
126 | / with A() as a:
127 | | with B() as b:
| |__________________^ SIM117
128 | type ListOrSet[T] = list[T] | set[T]
|
= help: Combine `with` statements

Suggested fix
123 123 | f(b2, c2, d2)
124 124 |
125 125 | # SIM117
126 |-with A() as a:
127 |- with B() as b:
128 |- type ListOrSet[T] = list[T] | set[T]
126 |+with A() as a, B() as b:
127 |+ type ListOrSet[T] = list[T] | set[T]
129 128 |
130 |- class ClassA[T: str]:
131 |- def method1(self) -> T:
132 |- ...
129 |+ class ClassA[T: str]:
130 |+ def method1(self) -> T:
131 |+ ...
133 132 |
134 |- f" something { my_dict["key"] } something else "
133 |+ f" something { my_dict["key"] } something else "
135 134 |
136 |- f"foo {f"bar {x}"} baz"
135 |+ f"foo {f"bar {x}"} baz"


0 comments on commit 75f759e

Please sign in to comment.