Skip to content

Commit 89d96bf

Browse files
committed
Add types to TinyTableBlock.__init__()
1 parent 7a32474 commit 89d96bf

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/wagtail_tinytableblock/blocks.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
from django import forms
66
from django.forms import Media
77
from django.utils.functional import cached_property
8-
from wagtail.blocks import FieldBlock, StructBlock
8+
from collections.abc import Iterable
9+
from wagtail.blocks import Block, FieldBlock, StructBlock
910
from wagtail.blocks.field_block import CharBlock, FieldBlockAdapter
1011

1112
from .utils import html_table_to_dict
@@ -17,6 +18,9 @@
1718
from wagtail.telepath import register
1819

1920

21+
type BlockDefinitions = Iterable[tuple[str, Block] | list[str | Block]]
22+
23+
2024
class TinyTableFieldBlock(FieldBlock):
2125
def __init__(
2226
self, *, required: bool = True, help_text: str | None = None, **kwargs: Any
@@ -86,7 +90,10 @@ class TinyTableBlock(StructBlock):
8690
title = CharBlock(required=False)
8791
caption = CharBlock(required=False)
8892

89-
def __init__(self, *, local_blocks=(), search_index=True, **kwargs):
93+
def __init__(self, local_blocks: BlockDefinitions | None = None, search_index: bool = True, **kwargs) -> None: # noqa: FBT001,FBT002
94+
if local_blocks is None:
95+
local_blocks = ()
96+
9097
# Manually define the data block so we can pass on configuration kwargs.
9198
data_block = TinyTableFieldBlock(
9299
required=False,

0 commit comments

Comments
 (0)