Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SnackBar Fail #3499

Closed
1 task done
joeg-ita opened this issue Jun 20, 2024 · 0 comments · Fixed by #3507
Closed
1 task done

SnackBar Fail #3499

joeg-ita opened this issue Jun 20, 2024 · 0 comments · Fixed by #3507
Assignees
Labels
bug: regression A feature that worked correctly doesn't anymore has reproducible steps Issue is reproducible

Comments

@joeg-ita
Copy link

Duplicate Check

Describe the bug

Pyhton 3.9
Flet 0.23.1

Executing the snackbar control example now return the error:

File "/home/[omissis]/venv/lib64/python3.9/site-packages/flet_core/snack_bar.py", line 132, in before_update
if isinstance(self.__margin, Union[int, float, Padding]) and not self.width:
File "/usr/lib64/python3.9/typing.py", line 720, in instancecheck
return self.subclasscheck(type(obj))
File "/usr/lib64/python3.9/typing.py", line 723, in subclasscheck
raise TypeError("Subscripted generics cannot be used with"
TypeError: Subscripted generics cannot be used with class and instance checks

Setting margin (as int or float or Padding) or witdh doesn't change the result

Code

import flet as ft

class Data:
def init(self) -> None:
self.counter = 0

d = Data()

def main(page):

page.snack_bar = ft.SnackBar(
    content=ft.Text("Hello, world!"),
    action="Alright!",
)

def on_click(e):
    page.snack_bar = ft.SnackBar(ft.Text(f"Hello {d.counter}"))
    page.snack_bar.open = True
    d.counter += 1
    page.update()

page.add(ft.ElevatedButton("Open SnackBar", on_click=on_click))

ft.app(target=main)

To reproduce

run https://flet.dev/docs/controls/snackbar

Expected behavior

No response

Screenshots

No response

Operating System

Linux

Operating system details

RHEL8

Flet version

0.23.1

Regression

Yes, it used to work in a previous Flet version (please specify the version in additional details)

Suggestions

No response

Additional details

No response

@ndonkoHenri ndonkoHenri added has reproducible steps Issue is reproducible bug: regression A feature that worked correctly doesn't anymore labels Jun 20, 2024
@ndonkoHenri ndonkoHenri self-assigned this Jun 20, 2024
ndonkoHenri added a commit that referenced this issue Jun 21, 2024
…_update method

- Corrected isinstance check in SnackBar.before_update to use a tuple of types instead of Union, resolving TypeError: "Subscripted generics cannot be used with class and instance checks".
@ndonkoHenri ndonkoHenri linked a pull request Jun 21, 2024 that will close this issue
@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Done in Flet Development Jun 24, 2024
zrr1999 pushed a commit to zrr1999/flet that referenced this issue Jul 17, 2024
* Fix flet-dev#3503: `Slider.value` defaults to `min`

* Fix flet-dev#3505: add "hide" and "show" to  WindowEventType enum

* Fix flet-dev#3499: TypeError raised for isinstance check with Union in before_update method

- Corrected isinstance check in SnackBar.before_update to use a tuple of types instead of Union, resolving TypeError: "Subscripted generics cannot be used with class and instance checks".

* Fix `Page.open()` breaking after multiple calls

* Fix flet-dev#3516: delete Page.window.on_resize | deprecate Page.on_resize in favor of Page.on_resized

* Page: Typo in on_resized setter decorator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: regression A feature that worked correctly doesn't anymore has reproducible steps Issue is reproducible
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants