Skip to content

Commit 3052f4f

Browse files
INTEG-3042 - upgrade pydantic
1 parent 529eebc commit 3052f4f

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ dependencies = [
2828
"requests",
2929
"requests-toolbelt",
3030
"rich",
31-
"pydantic>=2.11,<2.12",
31+
"pydantic>=2.11",
3232
"pydantic-settings",
3333
"isodate",
3434
"python-dateutil",

src/_incydr_cli/cmds/trusted_activities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def _output_trusted_activity(
334334
t.add_column("Action Groups")
335335

336336
# exclude activity action groups from the info panel
337-
include = list(TrustedActivity.__fields__.keys())
337+
include = list(TrustedActivity.model_fields.keys())
338338
include.remove("activity_action_groups")
339339
t.add_row(
340340
model_as_card(

src/_incydr_sdk/utils.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,11 @@ class Parent(BaseModel):
182182
model = type(model)
183183
for name, field in model.model_fields.items():
184184
model_field_type = _get_model_type(field.annotation)
185-
if _is_single(field.annotation) and issubclass(model_field_type, BaseModel):
185+
if (
186+
_is_single(field.annotation)
187+
and isinstance(model_field_type, type)
188+
and issubclass(model_field_type, BaseModel)
189+
):
186190
for child_name in flatten_fields(model_field_type):
187191
yield f"{name}.{child_name}"
188192
else:
@@ -239,13 +243,17 @@ def _is_single(type) -> bool:
239243
return True
240244

241245

242-
def _get_model_type(type) -> Type[BaseModel]:
246+
def _get_model_type(inputType) -> Type[BaseModel]:
243247
"""Given a type annotation, gets the type that subclasses BaseModel"""
244-
if issubclass(type, BaseModel):
245-
return type
246-
elif get_origin(type):
248+
if isinstance(inputType, type) and issubclass(inputType, BaseModel):
249+
return inputType
250+
elif get_origin(inputType):
247251
return next(
248-
(_get_model_type(item) for item in get_args(type) if _get_model_type(item)),
252+
(
253+
_get_model_type(item)
254+
for item in get_args(inputType)
255+
if _get_model_type(item)
256+
),
249257
None,
250258
)
251259
return None

0 commit comments

Comments
 (0)