Skip to content

Commit 6684820

Browse files
committed
Add overloads to control decorator function
Introduced @overload annotations for the control decorator to improve type hinting and clarify supported call signatures.
1 parent a93b193 commit 6684820

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

sdk/python/packages/flet/src/flet/controls/base_control.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import logging
44
import sys
55
from dataclasses import InitVar, dataclass, field
6-
from typing import TYPE_CHECKING, Any, Callable, Optional, TypeVar, Union
6+
from typing import TYPE_CHECKING, Any, Callable, Optional, TypeVar, Union, overload
77

88
from flet.controls.context import _context_page, context
99
from flet.controls.control_event import ControlEvent, get_event_field_type
@@ -40,6 +40,20 @@ def skip_field():
4040
T = TypeVar("T", bound="BaseControl")
4141

4242

43+
@overload
44+
def control(cls: type[T]) -> type[T]: ...
45+
46+
47+
@overload
48+
def control(
49+
dart_widget_name: Optional[Union[type[T], str]] = None,
50+
*,
51+
isolated: Optional[bool] = None,
52+
post_init_args: int = 1,
53+
**dataclass_kwargs: Any,
54+
) -> Callable[[type[T]], type[T]]: ...
55+
56+
4357
@dataclass_transform()
4458
def control(
4559
dart_widget_name: Optional[Union[type[T], str]] = None,

0 commit comments

Comments
 (0)