From 930ac1571bb977a24adf4ff0371b5d21e6d48b4f Mon Sep 17 00:00:00 2001 From: Michael Carlstrom Date: Tue, 24 Dec 2024 10:57:28 -0800 Subject: [PATCH] Simplfication of isinstance checks Signed-off-by: Michael Carlstrom --- .../__init__.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/rosidl_generator_type_description/rosidl_generator_type_description/__init__.py b/rosidl_generator_type_description/rosidl_generator_type_description/__init__.py index 4b46da56a..dd6445a94 100644 --- a/rosidl_generator_type_description/rosidl_generator_type_description/__init__.py +++ b/rosidl_generator_type_description/rosidl_generator_type_description/__init__.py @@ -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 @@ -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