@@ -285,7 +285,7 @@ def test_render_template_default_member_values() -> None:
285285
286286 result = py_gen ._render_template (parsed_idl , {"package" : "test" })
287287
288- assert "foo: int = 42" .replace (" " , "" ) in result .replace (" " , "" )
288+ assert "foo: Optional[ int] = 42" .replace (" " , "" ) in result .replace (" " , "" )
289289 assert "bar: Optional[int] = None" .replace (" " , "" ) in result .replace (" " , "" )
290290
291291
@@ -564,7 +564,7 @@ def test__render_template_string_default_value() -> None:
564564 for match in matches :
565565 struct_body = match [2 ]
566566 if match [0 ] == "Foo" :
567- assert 'foo: str = "bar"' .replace (" " , "" ) in struct_body .replace (" " , "" )
567+ assert 'foo: Optional[ str] = "bar"' .replace (" " , "" ) in struct_body .replace (" " , "" )
568568
569569
570570def test_render_template_struct_with_empty_type_default () -> None :
@@ -600,7 +600,7 @@ def test_render_template_struct_with_empty_type_default() -> None:
600600 for match in matches :
601601 struct_body = match [2 ]
602602 if match [0 ] == "Data" :
603- assert 'base: Annotated[Union["Foo", "Bar", "Base"],Field(discriminator="type")] = Foo()' .replace (
603+ assert 'base: Optional[ Annotated[Union["Foo", "Bar", "Base"],Field(discriminator="type")] ] = Foo()' .replace (
604604 " " , ""
605605 ) in struct_body .replace (" " , "" )
606606 elif match [0 ] == "Base" :
@@ -609,7 +609,7 @@ def test_render_template_struct_with_empty_type_default() -> None:
609609 assert 'type: Literal["Foo"] = "Foo"' .replace (" " , "" ) in struct_body .replace (" " , "" )
610610 elif match [0 ] == "Bar" :
611611 assert 'type: Literal["Bar"] = "Bar"' .replace (" " , "" ) in struct_body .replace (" " , "" )
612- assert "value: int = int()" .replace (" " , "" ) in struct_body .replace (" " , "" )
612+ assert "value: Optional[ int] = int()" .replace (" " , "" ) in struct_body .replace (" " , "" )
613613
614614
615615def test__render_template_boolean_default_value () -> None :
@@ -630,5 +630,5 @@ def test__render_template_boolean_default_value() -> None:
630630 for match in matches :
631631 struct_body = match [2 ]
632632 if match [0 ] == "Foo" :
633- assert "foo: bool = True" .replace (" " , "" ) in struct_body .replace (" " , "" )
634- assert "bar: bool = False" .replace (" " , "" ) in struct_body .replace (" " , "" )
633+ assert "foo: Optional[ bool] = True" .replace (" " , "" ) in struct_body .replace (" " , "" )
634+ assert "bar: Optional[ bool] = False" .replace (" " , "" ) in struct_body .replace (" " , "" )
0 commit comments