Skip to content

Commit 9f6913c

Browse files
authored
[red-knot] Update salsa (#17320)
## Summary Update Salsa to pull in salsa-rs/salsa#788 which fixes the, by now, famous *access to field whilst the value is being initialized*. This PR also re-enables all tests that previously triggered the panic. ## Test Plan `cargo test`
1 parent 5fef4d4 commit 9f6913c

File tree

4 files changed

+15
-19
lines changed

4 files changed

+15
-19
lines changed

Cargo.lock

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

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ rayon = { version = "1.10.0" }
124124
regex = { version = "1.10.2" }
125125
rustc-hash = { version = "2.0.0" }
126126
# When updating salsa, make sure to also update the revision in `fuzz/Cargo.toml`
127-
salsa = { git = "https://github.com/salsa-rs/salsa.git", rev = "c999c713d757b857b13f23fe38acc40ec5b4134c" }
127+
salsa = { git = "https://github.com/salsa-rs/salsa.git", rev = "b165ba7bd1b2a0112ce574a082ab8ea5102252ac" }
128128
schemars = { version = "0.8.16" }
129129
seahash = { version = "4.1.0" }
130130
serde = { version = "1.0.197", features = ["derive"] }

crates/red_knot_python_semantic/resources/mdtest/properties.md

+10-14
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,10 @@ reveal_type(c.attr) # revealed: Unknown
196196

197197
## Behind the scenes
198198

199-
> TODO: This test is currently disabled pending
200-
> [an upstream Salsa fix](https://github.com/salsa-rs/salsa/pull/741). Once that has been merged,
201-
> re-enable this test by changing the language codes below back to `py`.
202-
203199
In this section, we trace through some of the steps that make properties work. We start with a
204200
simple class `C` and a property `attr`:
205201

206-
```ignore
202+
```py
207203
class C:
208204
def __init__(self):
209205
self._attr: int = 0
@@ -220,7 +216,7 @@ class C:
220216
Next, we create an instance of `C`. As we have seen above, accessing `attr` on the instance will
221217
return an `int`:
222218

223-
```ignore
219+
```py
224220
c = C()
225221

226222
reveal_type(c.attr) # revealed: int
@@ -230,7 +226,7 @@ Behind the scenes, when we write `c.attr`, the first thing that happens is that
230226
up the symbol `attr` on the meta-type of `c`, i.e. the class `C`. We can emulate this static lookup
231227
using `inspect.getattr_static`, to see that `attr` is actually an instance of the `property` class:
232228

233-
```ignore
229+
```py
234230
from inspect import getattr_static
235231

236232
attr_property = getattr_static(C, "attr")
@@ -241,7 +237,7 @@ The `property` class has a `__get__` method, which makes it a descriptor. It als
241237
method, which means that it is a *data* descriptor (if there is no setter, `__set__` is still
242238
available but yields an `AttributeError` at runtime).
243239

244-
```ignore
240+
```py
245241
reveal_type(type(attr_property).__get__) # revealed: <wrapper-descriptor `__get__` of `property` objects>
246242
reveal_type(type(attr_property).__set__) # revealed: <wrapper-descriptor `__set__` of `property` objects>
247243
```
@@ -250,22 +246,22 @@ When we access `c.attr`, the `__get__` method of the `property` class is called,
250246
property object itself as the first argument, and the class instance `c` as the second argument. The
251247
third argument is the "owner" which can be set to `None` or to `C` in this case:
252248

253-
```ignore
249+
```py
254250
reveal_type(type(attr_property).__get__(attr_property, c, C)) # revealed: int
255251
reveal_type(type(attr_property).__get__(attr_property, c, None)) # revealed: int
256252
```
257253

258254
Alternatively, the above can also be written as a method call:
259255

260-
```ignore
256+
```py
261257
reveal_type(attr_property.__get__(c, C)) # revealed: int
262258
```
263259

264260
When we access `attr` on the class itself, the descriptor protocol is also invoked, but the instance
265261
argument is set to `None`. When `instance` is `None`, the call to `property.__get__` returns the
266262
property instance itself. So the following expressions are all equivalent
267263

268-
```ignore
264+
```py
269265
reveal_type(attr_property) # revealed: property
270266
reveal_type(C.attr) # revealed: property
271267
reveal_type(attr_property.__get__(None, C)) # revealed: property
@@ -275,7 +271,7 @@ reveal_type(type(attr_property).__get__(attr_property, None, C)) # revealed: pr
275271
When we set the property using `c.attr = "a"`, the `__set__` method of the property class is called.
276272
This attribute access desugars to
277273

278-
```ignore
274+
```py
279275
type(attr_property).__set__(attr_property, c, "a")
280276

281277
# error: [call-non-callable] "Call of wrapper descriptor `property.__set__` failed: calling the setter failed"
@@ -284,7 +280,7 @@ type(attr_property).__set__(attr_property, c, 1)
284280

285281
which is also equivalent to the following expressions:
286282

287-
```ignore
283+
```py
288284
attr_property.__set__(c, "a")
289285
# error: [call-non-callable]
290286
attr_property.__set__(c, 1)
@@ -297,7 +293,7 @@ C.attr.__set__(c, 1)
297293
Properties also have `fget` and `fset` attributes that can be used to retrieve the original getter
298294
and setter functions, respectively.
299295

300-
```ignore
296+
```py
301297
reveal_type(attr_property.fget) # revealed: Literal[attr]
302298
reveal_type(attr_property.fget(c)) # revealed: int
303299

fuzz/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ ruff_python_formatter = { path = "../crates/ruff_python_formatter" }
2929
ruff_text_size = { path = "../crates/ruff_text_size" }
3030

3131
libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer", default-features = false }
32-
salsa = { git = "https://github.com/salsa-rs/salsa.git", rev = "c999c713d757b857b13f23fe38acc40ec5b4134c" }
32+
salsa = { git = "https://github.com/salsa-rs/salsa.git", rev = "b165ba7bd1b2a0112ce574a082ab8ea5102252ac" }
3333
similar = { version = "2.5.0" }
3434
tracing = { version = "0.1.40" }
3535

0 commit comments

Comments
 (0)