Skip to content

Commit 5b2510c

Browse files
committed
Fix type warning from ty
error[invalid-argument-type]: Argument to function `render_blocks` is incorrect --> tests/integration_test.py:56:30 | 56 | blocks=render_blocks(blocks), | ^^^^^^ Expected `list[Block]`, found `list[Header | Divider | MarkdownSection | MarkdownSectionFields | CodeBlock]` | info: Function defined here --> ca_slack_block_kit/__init__.py:38:5 | 38 | def render_blocks(blocks: list["Block"]) -> list[dict]: | ^^^^^^^^^^^^^ --------------------- Parameter declared here | info: `list` is invariant in its type parameter info: Consider using the covariant supertype `collections.abc.Sequence` info: For more information, see https://docs.astral.sh/ty/reference/typing-faq/#invariant-generics
1 parent 68b2deb commit 5b2510c

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

ca_slack_block_kit/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"""
1010

1111
from abc import ABC, abstractmethod
12+
from collections.abc import Sequence
1213
from dataclasses import dataclass
1314

1415

@@ -35,7 +36,7 @@ class Emoji:
3536
SPARKLES = ":sparkles:"
3637

3738

38-
def render_blocks(blocks: list["Block"]) -> list[dict]:
39+
def render_blocks(blocks: Sequence["Block"]) -> list[dict]:
3940
"""Render a list of Block objects into a list of dictionaries compatible with the Slack SDK client chat_postMessage function.
4041
4142
Args:

docs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Various emojis for easy use with Slack messages.
3939
#### render_blocks
4040

4141
```python
42-
def render_blocks(blocks: list["Block"]) -> list[dict]
42+
def render_blocks(blocks: Sequence["Block"]) -> list[dict]
4343
```
4444

4545
Render a list of Block objects into a list of dictionaries compatible with the Slack SDK client chat_postMessage function.

0 commit comments

Comments
 (0)