Skip to content

Commit dd3e039

Browse files
committed
chore: support multi-value detection for union types
1 parent 4c0fedb commit dd3e039

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

scim2_server/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import datetime
22
import importlib
33
import json
4+
from types import UnionType
45
from typing import Any
56
from typing import Union
67
from typing import get_args
@@ -102,7 +103,7 @@ def is_multi_valued(model: BaseModel, attribute_name: str) -> bool:
102103
"""Checks whether a given attribute of a model is multi-valued."""
103104
attribute_type = model.model_fields[attribute_name].annotation
104105

105-
if get_origin(attribute_type) is Union:
106+
if get_origin(attribute_type) in (Union, UnionType):
106107
attribute_type = get_args(attribute_type)[0]
107108

108109
origin = get_origin(attribute_type)

0 commit comments

Comments
 (0)