@@ -150,11 +150,10 @@ async def false_alarm():
150150 yield
151151
152152
153- # this would ideally error, but not worth the extra logic
154153@asynccontextmanager
155154async def should_error ():
156155 async with trio .open_nursery () as nursery :
157- nursery .start_soon (my_startable )
156+ nursery .start_soon (my_startable ) # ASYNC113: 8
158157 # overrides the nursery variable
159158 async with trio .open_nursery () as nursery :
160159 nursery .start_soon (my_startable )
@@ -169,14 +168,25 @@ async def foo_sync_with_closed():
169168 yield
170169
171170
172- # this one is surprisingly hard to fix
173- # the easiest way would be with a leave_AsyncFunctionDef, but that's only a thing in
174- # cst visitors; and we can't do the standard thing of manually visiting children in
175- # visit_AsyncFunctionDef because we need the interleaving of the utility visitor.
176- # So I either need to convert the visitor to cst, including VisitorTypeTracker, or
177- # add logic to Flake8AsyncRunner to also support leave_XXX.
178- # The latter is probably not too bad but... a tomorrow problem
171+ # fixed by entirely skipping nurseries without yields in them
179172class FalseAlarm :
180173 async def __aenter__ (self ):
181174 with trio .open_nursery () as nursery :
182- nursery .start_soon (my_startable ) # ASYNC113: 12
175+ nursery .start_soon (my_startable )
176+
177+
178+ @asynccontextmanager
179+ async def yield_before_start_soon ():
180+ with trio .open_nursery () as bar :
181+ yield
182+ bar .start_soon (my_startable )
183+
184+
185+ # This was broken when visit_AsyncWith manually visited subnodes due to not
186+ # letting TypeTrackerVisitor interject.
187+ @asynccontextmanager
188+ async def nested ():
189+ with trio .open_nursery () as foo :
190+ with trio .open_nursery () as bar :
191+ bar .start_soon (my_startable ) # error: 12
192+ yield
0 commit comments