Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
fix typing of add_pages() (#795)
Browse files Browse the repository at this point in the history
Co-authored-by: dinhlongnguyen <[email protected]>
  • Loading branch information
Dr-Irv and dinhlongviolin1 authored Jun 16, 2023
1 parent 3f5b387 commit a9a16a6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# required by black, https://github.com/psf/black/blob/master/.flake8
max-line-length = 120
max-complexity = 18
ignore = E203, E266, E501, E722, W503, F403, F401
ignore = E203, E266, E501, E722, W503, F403, F401, F811
select = B,C,E,F,W,T4,B9
docstring-convention = google
per-file-ignores =
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ repos:
- id: black
args: [--line-length=120]
language_version: python3
- repo: https://gitlab.com/pycqa/flake8
- repo: https://github.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
Expand Down
2 changes: 1 addition & 1 deletion src/taipy/gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ def add_page(
# Update variable directory
self.__var_dir.add_frame(page._frame)

def add_pages(self, pages: t.Optional[t.Union[t.Dict[str, t.Union[str, Page]], str]] = None) -> None:
def add_pages(self, pages: t.Optional[t.Union[t.Mapping[str, t.Union[str, Page]], str]] = None) -> None:
"""Add several pages to the Graphical User Interface.
Arguments:
Expand Down
30 changes: 28 additions & 2 deletions src/taipy/gui/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,36 @@ class PropertyType(Enum):
inner = "inner"


def _get_taipy_type(a_type: t.Optional[PropertyType]) -> t.Optional[t.Type[_TaipyBase]]:
@t.overload
def _get_taipy_type(a_type: None) -> None:
...


@t.overload
def _get_taipy_type(a_type: t.Type[_TaipyBase]) -> t.Type[_TaipyBase]:
...


@t.overload
def _get_taipy_type(a_type: PropertyType) -> t.Type[_TaipyBase]:
...


@t.overload
def _get_taipy_type(
a_type: t.Optional[t.Union[t.Type[_TaipyBase], t.Type[Decimator], PropertyType]]
) -> t.Optional[t.Union[t.Type[_TaipyBase], t.Type[Decimator], PropertyType]]:
...


def _get_taipy_type(
a_type: t.Optional[t.Union[t.Type[_TaipyBase], t.Type[Decimator], PropertyType]]
) -> t.Optional[t.Union[t.Type[_TaipyBase], t.Type[Decimator], PropertyType]]:
if a_type is None:
return None
if isinstance(a_type, PropertyType) and not isinstance(a_type.value, str):
return a_type.value
if isclass(a_type) and issubclass(a_type, _TaipyBase):
if isclass(a_type) and not isinstance(a_type, PropertyType) and issubclass(a_type, _TaipyBase):
return a_type
if a_type == PropertyType.boolean:
return _TaipyBool
Expand Down

0 comments on commit a9a16a6

Please sign in to comment.