4646 TiledConfig ,
4747)
4848from blueapi .core import BlueskyContext , is_bluesky_compatible_device
49- from blueapi .core .context import DefaultFactory , generic_bounds , qualified_name
49+ from blueapi .core .context import generic_bounds , qualified_name
5050from blueapi .core .protocols import DeviceConnectResult , DeviceManager
5151from blueapi .utils .connect_devices import _establish_device_connections
5252from blueapi .utils .invalid_config_error import InvalidConfigError
@@ -431,9 +431,9 @@ def test_with_config_passes_mock_to_with_dodal_module(
431431def test_function_spec (empty_context : BlueskyContext ):
432432 spec = empty_context ._type_spec_for_function (has_some_params )
433433 assert spec ["foo" ][0 ] is int
434- assert spec ["foo" ][1 ].default_factory == DefaultFactory ( 42 )
434+ assert spec ["foo" ][1 ].default == 42
435435 assert spec ["bar" ][0 ] is str
436- assert spec ["bar" ][1 ].default_factory == DefaultFactory ( "bar" )
436+ assert spec ["bar" ][1 ].default == "bar"
437437
438438
439439def test_basic_type_conversion (empty_context : BlueskyContext ):
@@ -514,7 +514,7 @@ def default_movable(mov: Movable = inject("demo")) -> MsgGenerator:
514514 spec = empty_context ._type_spec_for_function (default_movable )
515515 movable_ref = empty_context ._reference (Movable )
516516 assert spec ["mov" ][0 ] == movable_ref
517- assert spec ["mov" ][1 ].default_factory == DefaultFactory ( "demo" )
517+ assert spec ["mov" ][1 ].default == "demo"
518518
519519
520520def test_generic_default_device_reference (empty_context : BlueskyContext ):
@@ -524,7 +524,7 @@ def default_movable(mov: Movable[float] = inject("demo")) -> MsgGenerator:
524524 spec = empty_context ._type_spec_for_function (default_movable )
525525 motor_ref = empty_context ._reference (Movable [float ])
526526 assert spec ["mov" ][0 ] == motor_ref
527- assert spec ["mov" ][1 ].default_factory == DefaultFactory ( "demo" )
527+ assert spec ["mov" ][1 ].default == "demo"
528528
529529
530530class ConcreteStoppable (Stoppable ):
@@ -574,7 +574,7 @@ def test_str_default(empty_context: BlueskyContext, sim_motor: Motor, alt_motor:
574574
575575 spec = empty_context ._type_spec_for_function (has_default_reference )
576576 assert spec ["m" ][0 ] is movable_ref
577- assert ( df := spec ["m" ][1 ].default_factory ) and df () == SIM_MOTOR_NAME # type: ignore
577+ assert spec ["m" ][1 ].default == SIM_MOTOR_NAME
578578
579579 assert has_default_reference .__name__ in empty_context .plans
580580 model = empty_context .plans [has_default_reference .__name__ ].model
@@ -593,7 +593,7 @@ def test_nested_str_default(
593593
594594 spec = empty_context ._type_spec_for_function (has_default_nested_reference )
595595 assert spec ["m" ][0 ] == list [movable_ref ]
596- assert ( df := spec ["m" ][1 ].default_factory ) and df () == [SIM_MOTOR_NAME ] # type: ignore
596+ assert spec ["m" ][1 ].default == [SIM_MOTOR_NAME ]
597597
598598 assert has_default_nested_reference .__name__ in empty_context .plans
599599 model = empty_context .plans [has_default_nested_reference .__name__ ].model
@@ -697,7 +697,7 @@ def demo_plan(foo: int | None = None) -> MsgGenerator:
697697 empty_context .register_plan (demo_plan )
698698 schema = empty_context .plans ["demo_plan" ].model .model_json_schema ()
699699 assert schema ["properties" ] == {
700- "foo" : {"title" : "Foo" , "type" : "integer" },
700+ "foo" : {"title" : "Foo" , "type" : "integer" , "default" : None },
701701 }
702702 assert "foo" not in schema .get ("required" , [])
703703
@@ -725,7 +725,11 @@ def demo_plan(foo: int | str | None = None) -> MsgGenerator:
725725 empty_context .register_plan (demo_plan )
726726 schema = empty_context .plans ["demo_plan" ].model .model_json_schema ()
727727 assert schema ["properties" ] == {
728- "foo" : {"title" : "Foo" , "anyOf" : [{"type" : "integer" }, {"type" : "string" }]}
728+ "foo" : {
729+ "title" : "Foo" ,
730+ "anyOf" : [{"type" : "integer" }, {"type" : "string" }],
731+ "default" : None ,
732+ }
729733 }
730734 assert "foo" not in schema .get ("required" , [])
731735
@@ -739,7 +743,10 @@ def demo_plan(foo: int | None) -> MsgGenerator:
739743 empty_context .register_plan (demo_plan )
740744 schema = empty_context .plans ["demo_plan" ].model .model_json_schema ()
741745 assert schema ["properties" ] == {
742- "foo" : {"title" : "Foo" , "anyOf" : [{"type" : "integer" }, {"type" : "null" }]}
746+ "foo" : {
747+ "title" : "Foo" ,
748+ "anyOf" : [{"type" : "integer" }, {"type" : "null" }],
749+ }
743750 }
744751 assert "foo" in schema .get ("required" , [])
745752
0 commit comments