Use within-scope shadowed bindings in `asyncio-dangling-task` (#10793)

## Summary

I think this is using the wrong shadowing, as seen by the change in the
test fixture.
This commit is contained in:
Charlie Marsh 2024-04-06 10:44:03 -04:00 committed by GitHub
parent b45fd61ec5
commit 83db62bcda
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 4 deletions

View File

@ -139,8 +139,7 @@ pub(crate) fn asyncio_dangling_binding(
// else:
// task = asyncio.create_task(make_request())
// ```
for binding_id in
std::iter::successors(Some(binding_id), |id| semantic.shadowed_binding(*id))
for binding_id in std::iter::successors(Some(binding_id), |id| scope.shadowed_binding(*id))
{
let binding = semantic.binding(binding_id);
if binding.is_used()

View File

@ -41,6 +41,16 @@ RUF006.py:97:5: RUF006 Store a reference to the return value of `loop.create_tas
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF006
|
RUF006.py:152:13: RUF006 Store a reference to the return value of `asyncio.create_task`
|
150 | async def f(x: bool):
151 | if x:
152 | t = asyncio.create_task(asyncio.sleep(1))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF006
153 | else:
154 | t = None
|
RUF006.py:170:5: RUF006 Store a reference to the return value of `loop.create_task`
|
168 | def f():
@ -60,5 +70,3 @@ RUF006.py:175:5: RUF006 Store a reference to the return value of `loop.create_ta
176 |
177 | # OK
|