@@ -392,7 +392,7 @@ async def do_execute(
392392 if hasattr (shell , "run_cell_async" ) and hasattr (shell , "should_run_async" ):
393393 run_cell = shell .run_cell_async
394394 should_run_async = shell .should_run_async
395- accepts_params = _accepts_parameters (run_cell , ["cell_id" ])
395+ accepts_params = _accepts_parameters (run_cell , ["cell_id" , "cell_meta" ])
396396 else :
397397 should_run_async = lambda cell : False # noqa: ARG005, E731
398398 # older IPython,
@@ -401,7 +401,7 @@ async def do_execute(
401401 async def run_cell (* args , ** kwargs ):
402402 return shell .run_cell (* args , ** kwargs )
403403
404- accepts_params = _accepts_parameters (shell .run_cell , ["cell_id" ])
404+ accepts_params = _accepts_parameters (shell .run_cell , ["cell_id" , "cell_meta" ])
405405 try :
406406 # default case: runner is asyncio and asyncio is already running
407407 # TODO: this should check every case for "are we inside the runner",
@@ -413,6 +413,12 @@ async def run_cell(*args, **kwargs):
413413 transformed_cell = code
414414 preprocessing_exc_tuple = sys .exc_info ()
415415
416+ do_execute_args = {}
417+ if accepts_params ["cell_meta" ]:
418+ do_execute_args ["cell_meta" ] = cell_meta
419+ if accepts_params ["cell_id" ]:
420+ do_execute_args ["cell_id" ] = cell_id
421+
416422 if (
417423 _asyncio_runner # type:ignore[truthy-bool]
418424 and shell .loop_runner is _asyncio_runner
@@ -423,23 +429,14 @@ async def run_cell(*args, **kwargs):
423429 preprocessing_exc_tuple = preprocessing_exc_tuple ,
424430 )
425431 ):
426- if accepts_params ["cell_id" ]:
427- coro = run_cell (
428- code ,
429- store_history = store_history ,
430- silent = silent ,
431- transformed_cell = transformed_cell ,
432- preprocessing_exc_tuple = preprocessing_exc_tuple ,
433- cell_id = cell_id ,
434- )
435- else :
436- coro = run_cell (
437- code ,
438- store_history = store_history ,
439- silent = silent ,
440- transformed_cell = transformed_cell ,
441- preprocessing_exc_tuple = preprocessing_exc_tuple ,
442- )
432+ coro = run_cell (
433+ code ,
434+ store_history = store_history ,
435+ silent = silent ,
436+ transformed_cell = transformed_cell ,
437+ preprocessing_exc_tuple = preprocessing_exc_tuple ,
438+ ** do_execute_args ,
439+ )
443440
444441 coro_future = asyncio .ensure_future (coro )
445442
@@ -460,15 +457,9 @@ async def run_cell(*args, **kwargs):
460457 # runner isn't already running,
461458 # make synchronous call,
462459 # letting shell dispatch to loop runners
463- if accepts_params ["cell_id" ]:
464- res = shell .run_cell (
465- code ,
466- store_history = store_history ,
467- silent = silent ,
468- cell_id = cell_id ,
469- )
470- else :
471- res = shell .run_cell (code , store_history = store_history , silent = silent )
460+ res = shell .run_cell (
461+ code , store_history = store_history , silent = silent , ** do_execute_args
462+ )
472463 finally :
473464 self ._restore_input ()
474465
0 commit comments