@@ -12,6 +12,15 @@ def __str__(self):
1212 return f"<slack_sdk.{ self .__class__ .__name__ } >"
1313
1414
15+ # Usually, Block Kit components do not allow an empty array for a property value, but there are some exceptions.
16+ EMPTY_ALLOWED_TYPE_AND_PROPERTY_LIST = [
17+ {"type" : "rich_text_section" , "property" : "elements" },
18+ {"type" : "rich_text_list" , "property" : "elements" },
19+ {"type" : "rich_text_preformatted" , "property" : "elements" },
20+ {"type" : "rich_text_quote" , "property" : "elements" },
21+ ]
22+
23+
1524class JsonObject (BaseObject , metaclass = ABCMeta ):
1625 """The base class for JSON serializable class objects"""
1726
@@ -51,6 +60,14 @@ def is_not_empty(self, key: str) -> bool:
5160 value = getattr (self , key , None )
5261 if value is None :
5362 return False
63+
64+ # Usually, Block Kit components do not allow an empty array for a property value, but there are some exceptions.
65+ # The following code deals with these exceptions:
66+ type_value = getattr (self , "type" , None )
67+ for empty_allowed in EMPTY_ALLOWED_TYPE_AND_PROPERTY_LIST :
68+ if type_value == empty_allowed ["type" ] and key == empty_allowed ["property" ]:
69+ return True
70+
5471 has_len = getattr (value , "__len__" , None ) is not None
5572 if has_len : # skipcq: PYL-R1705
5673 return len (value ) > 0
0 commit comments