mirror of https://github.com/astral-sh/ruff
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:
parent
b45fd61ec5
commit
83db62bcda
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue