Skip to content

Commit

Permalink
Simplfication of isinstance checks
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
  • Loading branch information
InvincibleRMC committed Dec 24, 2024
1 parent 6a6ad9a commit 930ac15
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,11 @@ def field_type_type_id(ftype: definition.AbstractType) -> int:


def field_type_capacity(ftype: definition.AbstractType) -> int:
if isinstance(ftype, definition.AbstractNestedType):
if isinstance(ftype, definition.Array):
return ftype.size
elif isinstance(ftype, definition.BoundedSequence):
return ftype.maximum_size
if isinstance(ftype, definition.Array):
return ftype.size
elif isinstance(ftype, definition.BoundedSequence):
return ftype.maximum_size

return 0


Expand All @@ -425,9 +425,9 @@ def field_type_string_capacity(ftype: definition.AbstractType) -> Union[int, str
if isinstance(ftype, definition.AbstractNestedType):
value_type = ftype.value_type

if isinstance(value_type, definition.AbstractGenericString):
if isinstance(value_type, (definition.BoundedString, definition.BoundedWString)):
return value_type.maximum_size
if isinstance(value_type, (definition.BoundedString, definition.BoundedWString)):
return value_type.maximum_size

return 0


Expand Down

0 comments on commit 930ac15

Please sign in to comment.