@@ -40,6 +40,15 @@ <h1 class="title">Module <code>slack_sdk.models.basic_objects</code></h1>
4040 return f"<slack_sdk.{self.__class__.__name__}>"
4141
4242
43+ # Usually, Block Kit components do not allow an empty array for a property value, but there are some exceptions.
44+ EMPTY_ALLOWED_TYPE_AND_PROPERTY_LIST = [
45+ {"type": "rich_text_section", "property": "elements"},
46+ {"type": "rich_text_list", "property": "elements"},
47+ {"type": "rich_text_preformatted", "property": "elements"},
48+ {"type": "rich_text_quote", "property": "elements"},
49+ ]
50+
51+
4352class JsonObject(BaseObject, metaclass=ABCMeta):
4453 """The base class for JSON serializable class objects"""
4554
@@ -79,6 +88,14 @@ <h1 class="title">Module <code>slack_sdk.models.basic_objects</code></h1>
7988 value = getattr(self, key, None)
8089 if value is None:
8190 return False
91+
92+ # Usually, Block Kit components do not allow an empty array for a property value, but there are some exceptions.
93+ # The following code deals with these exceptions:
94+ type_value = getattr(self, "type", None)
95+ for empty_allowed in EMPTY_ALLOWED_TYPE_AND_PROPERTY_LIST:
96+ if type_value == empty_allowed["type"] and key == empty_allowed["property"]:
97+ return True
98+
8299 has_len = getattr(value, "__len__", None) is not None
83100 if has_len: # skipcq: PYL-R1705
84101 return len(value) > 0
@@ -244,6 +261,14 @@ <h3>Ancestors</h3>
244261 value = getattr(self, key, None)
245262 if value is None:
246263 return False
264+
265+ # Usually, Block Kit components do not allow an empty array for a property value, but there are some exceptions.
266+ # The following code deals with these exceptions:
267+ type_value = getattr(self, "type", None)
268+ for empty_allowed in EMPTY_ALLOWED_TYPE_AND_PROPERTY_LIST:
269+ if type_value == empty_allowed["type"] and key == empty_allowed["property"]:
270+ return True
271+
247272 has_len = getattr(value, "__len__", None) is not None
248273 if has_len: # skipcq: PYL-R1705
249274 return len(value) > 0
@@ -357,6 +382,14 @@ <h3>Methods</h3>
357382 value = getattr(self, key, None)
358383 if value is None:
359384 return False
385+
386+ # Usually, Block Kit components do not allow an empty array for a property value, but there are some exceptions.
387+ # The following code deals with these exceptions:
388+ type_value = getattr(self, "type", None)
389+ for empty_allowed in EMPTY_ALLOWED_TYPE_AND_PROPERTY_LIST:
390+ if type_value == empty_allowed["type"] and key == empty_allowed["property"]:
391+ return True
392+
360393 has_len = getattr(value, "__len__", None) is not None
361394 if has_len: # skipcq: PYL-R1705
362395 return len(value) > 0
0 commit comments