##// END OF EJS Templates
Apply linter on interactiveshell.py
Gal B -
Show More
@@ -123,7 +123,7 b' _single_targets_nodes = (ast.AugAssign, ast.AnnAssign)'
123
123
124 # we still need to run things using the asyncio eventloop, but there is no
124 # we still need to run things using the asyncio eventloop, but there is no
125 # async integration
125 # async integration
126 from .async_helpers import (_asyncio_runner, _pseudo_sync_runner)
126 from .async_helpers import _asyncio_runner, _pseudo_sync_runner
127 from .async_helpers import _curio_runner, _trio_runner, _should_be_async
127 from .async_helpers import _curio_runner, _trio_runner, _should_be_async
128
128
129 #-----------------------------------------------------------------------------
129 #-----------------------------------------------------------------------------
@@ -3224,27 +3224,32 b' class InteractiveShell(SingletonConfigurable):'
3224 raise ValueError("Interactivity was %r" % interactivity)
3224 raise ValueError("Interactivity was %r" % interactivity)
3225
3225
3226 try:
3226 try:
3227
3227 def compare(code):
3228 def compare(code):
3228 is_async = (inspect.CO_COROUTINE & code.co_flags == inspect.CO_COROUTINE)
3229 is_async = inspect.CO_COROUTINE & code.co_flags == inspect.CO_COROUTINE
3229 return is_async
3230 return is_async
3230
3231
3231 # refactor that to just change the mod constructor.
3232 # refactor that to just change the mod constructor.
3232 to_run = []
3233 to_run = []
3233 for node in to_run_exec:
3234 for node in to_run_exec:
3234 to_run.append((node, 'exec'))
3235 to_run.append((node, "exec"))
3235
3236
3236 for node in to_run_interactive:
3237 for node in to_run_interactive:
3237 to_run.append((node, 'single'))
3238 to_run.append((node, "single"))
3238
3239
3239 for node,mode in to_run:
3240 for node, mode in to_run:
3240 if mode == 'exec':
3241 if mode == "exec":
3241 mod = Module([node], [])
3242 mod = Module([node], [])
3242 elif mode == 'single':
3243 elif mode == "single":
3243 mod = ast.Interactive([node])
3244 mod = ast.Interactive([node])
3244 with compiler.extra_flags(getattr(ast, 'PyCF_ALLOW_TOP_LEVEL_AWAIT', 0x0) if self.autoawait else 0x0):
3245 with compiler.extra_flags(
3246 getattr(ast, "PyCF_ALLOW_TOP_LEVEL_AWAIT", 0x0)
3247 if self.autoawait
3248 else 0x0
3249 ):
3245 code = compiler(mod, cell_name, mode)
3250 code = compiler(mod, cell_name, mode)
3246 asy = compare(code)
3251 asy = compare(code)
3247 if (await self.run_code(code, result, async_=asy)):
3252 if await self.run_code(code, result, async_=asy):
3248 return True
3253 return True
3249
3254
3250 # Flush softspace
3255 # Flush softspace
@@ -3302,7 +3307,7 b' class InteractiveShell(SingletonConfigurable):'
3302 try:
3307 try:
3303 try:
3308 try:
3304 self.hooks.pre_run_code_hook()
3309 self.hooks.pre_run_code_hook()
3305 if async_ :
3310 if async_:
3306 await eval(code_obj, self.user_global_ns, self.user_ns)
3311 await eval(code_obj, self.user_global_ns, self.user_ns)
3307 else:
3312 else:
3308 exec(code_obj, self.user_global_ns, self.user_ns)
3313 exec(code_obj, self.user_global_ns, self.user_ns)
General Comments 0
You need to be logged in to leave comments. Login now