Skip to content

Commit

Permalink
style format
Browse files Browse the repository at this point in the history
  • Loading branch information
mfleader committed May 1, 2024
1 parent 3946e32 commit 2008810
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 168 deletions.
151 changes: 0 additions & 151 deletions oneof_int_plugin.py

This file was deleted.

9 changes: 7 additions & 2 deletions src/arcaflow_plugin_sdk/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -2580,6 +2580,7 @@ def _to_openapi_fragment(
StrInt = typing.Union[int, str]
StrIntType = typing.TypeVar("StrIntType", bound=StrInt)


@dataclass
class OneOfSchema(_JSONSchemaGenerator, _OpenAPIGenerator):
types: typing.Union[
Expand Down Expand Up @@ -2810,7 +2811,9 @@ class OneOfStringSchema(OneOfSchema):
oneof_type: typing.Annotated[str, _name("One Of String Type Name")] = (
"_discriminated_string_"
)
discriminator_type: typing.Annotated[str, _name("Discriminator Type")] = "string"
discriminator_type: typing.Annotated[str, _name("Discriminator Type")] = (
"string"
)


@dataclass
Expand Down Expand Up @@ -2923,7 +2926,9 @@ class OneOfIntSchema(OneOfSchema):
oneof_type: typing.Annotated[str, _name("One Of Int Type Name")] = (
"_discriminated_int_"
)
discriminator_type: typing.Annotated[str, _name("Discriminator Type")] = "integer"
discriminator_type: typing.Annotated[str, _name("Discriminator Type")] = (
"integer"
)


@dataclass
Expand Down
29 changes: 14 additions & 15 deletions src/arcaflow_plugin_sdk/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,8 @@ def setUp(self):
),
"msg": PropertyType(schema.StringType()),
"code": PropertyType(schema.IntType()),
}),
},
),
"b": schema.ObjectType(
InlineInt2,
{
Expand All @@ -613,12 +614,12 @@ def setUp(self):
# does not exist on the source dataclass
# "code": PropertyType(schema.IntType()),
"msg2": PropertyType(schema.StringType()),
})
},
),
},
"a",
)


def test_inline_discriminator_missing(self):
with self.assertRaises(BadArgumentException) as cm:
schema.OneOfStringType(
Expand Down Expand Up @@ -822,15 +823,11 @@ def test_unserialize_embedded(self):
discriminator_field_name=discriminator_field_name,
discriminator_inlined=True,
)
unserialized_data: InlineInt = s.unserialize({
discriminator_field_name: 1,
"msg": "Hi again",
"code": 101
})
unserialized_data: InlineInt = s.unserialize(
{discriminator_field_name: 1, "msg": "Hi again", "code": 101}
)
self.assertIsInstance(unserialized_data, InlineInt)



def test_validation(self):
s = schema.OneOfStringType[Basic](
{
Expand Down Expand Up @@ -1611,8 +1608,6 @@ class TestData:
t.serialize(TestData(type(dict[str, str])))


from pprint import pprint

class JSONSchemaTest(unittest.TestCase):

def _execute_test_cases(self, test_cases):
Expand Down Expand Up @@ -2186,7 +2181,9 @@ def test_oneof_int_inline(self):
"union": schema.PropertyType(
schema.OneOfIntType(
{
inline_int_key: schema.RefType(InlineInt.__name__, scope),
inline_int_key: schema.RefType(
InlineInt.__name__, scope
),
inline_int2_key: schema.RefType(
InlineInt2.__name__, scope
),
Expand Down Expand Up @@ -2264,7 +2261,8 @@ def test_oneof_int_inline(self):
"additionalProperties": False,
"dependentRequired": {},
},
f"{InlineInt.__name__}_discriminated_int_{inline_int_key}": {
f"{InlineInt.__name__}"
+ f"_discriminated_int_{inline_int_key}": {
"type": "object",
"properties": {
"msg": {"type": "string"},
Expand All @@ -2291,7 +2289,8 @@ def test_oneof_int_inline(self):
"additionalProperties": False,
"dependentRequired": {},
},
f"{InlineInt2.__name__}_discriminated_int_{inline_int2_key}": {
f"{InlineInt2.__name__}"
+ f"_discriminated_int_{inline_int2_key}": {
"type": "object",
"properties": {
"msg2": {"type": "string"},
Expand Down

0 comments on commit 2008810

Please sign in to comment.