Skip to content

Commit 88b784e

Browse files
chore: remove anti-pattern for direct usage of context manager
1 parent 9ed80ca commit 88b784e

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

packages/textual-hmr/textual_hmr.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,7 @@ def on_changes(self, files: set[Path]):
181181
last_return = None
182182
last_return_code = 0
183183

184-
reloader = Reloader()
185-
await reloader.__aenter__()
186-
try:
184+
async with Reloader() as reloader:
187185
while need_restart:
188186
need_restart = False
189187
with reloader.error_filter:
@@ -196,8 +194,6 @@ def on_changes(self, files: set[Path]):
196194
finally:
197195
main_loop_started.clear()
198196
current_app = None
199-
finally:
200-
await reloader.__aexit__(None, None, None)
201197

202198
return last_return, last_return_code
203199

0 commit comments

Comments
 (0)