MCPcopy Index your code
hub / github.com/slackapi/python-slack-sdk / HeaderBlock

Class HeaderBlock

slack_sdk/models/blocks/blocks.py:542–579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

540
541
542class HeaderBlock(Block):
543 type = "header"
544 text_max_length = 150
545
546 @property
547 def attributes(self) -> Set[str]: # type: ignore[override]
548 return super().attributes.union({"text"})
549
550 def __init__(
551 self,
552 *,
553 block_id: Optional[str] = None,
554 text: Optional[Union[str, dict, TextObject]] = None,
555 **others: dict,
556 ):
557 """A header is a plain-text block that displays in a larger, bold font.
558 https://docs.slack.dev/reference/block-kit/blocks/header-block
559
560 Args:
561 block_id: A string acting as a unique identifier for a block. If not specified, one will be generated.
562 Maximum length for this field is 255 characters.
563 block_id should be unique for each message and each iteration of a message.
564 If a message is updated, use a new block_id.
565 text (required): The text for the block, in the form of a plain_text text object.
566 Maximum length for the text in this field is 150 characters.
567 """
568 super().__init__(type=self.type, block_id=block_id)
569 show_unknown_key_warning(self, others)
570
571 self.text = TextObject.parse(text, default_type=PlainTextObject.type) # type: ignore[arg-type]
572
573 @JsonValidator("text attribute must be specified")
574 def _validate_text(self):
575 return self.text is not None
576
577 @JsonValidator(f"text attribute cannot exceed {text_max_length} characters")
578 def _validate_alt_text_length(self):
579 return self.text is None or len(self.text.text) <= self.text_max_length
580
581
582class MarkdownBlock(Block):

Callers 7

test_documentMethod · 0.90
test_text_length_150Method · 0.90
test_text_length_151Method · 0.90
test_documentMethod · 0.90
test_text_length_150Method · 0.90
test_text_length_151Method · 0.90
parseMethod · 0.85

Calls

no outgoing calls

Tested by 6

test_documentMethod · 0.72
test_text_length_150Method · 0.72
test_text_length_151Method · 0.72
test_documentMethod · 0.72
test_text_length_150Method · 0.72
test_text_length_151Method · 0.72