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

Typing error on panel.state.notifications.error based on examples #6824

Open
wilsonnater opened this issue May 11, 2024 · 2 comments
Open

Typing error on panel.state.notifications.error based on examples #6824

wilsonnater opened this issue May 11, 2024 · 2 comments

Comments

@wilsonnater
Copy link

wilsonnater commented May 11, 2024

This feel like a bug, documentation issue, or implementation issue, but is probably a relatively low priority. The current way panel.state.notification is typed means the example uses of notifications will give an error from typing checking. (If it returned None, then calling error on it would fail). It appears to be originating at this line of code https://github.com/holoviz/panel/blob/main/panel/io/state.py#L1044

ALL software version info

panel 1.2.3
mypy 0.971
mypy-extensions 0.4.3

Description of expected behavior and the observed behavior

Mypy gives this error error: Item "None" of "Optional[NotificationArea]" has no attribute "error" on pn.state.notifications.error('This is an error notification.', duration=1000)

Complete, minimal, self-contained example code that reproduces the issue

import panel as pn

pn.extension("notifications")

pn.state.notifications.error('This is an error notification.', duration=1000)

Stack traceback and/or browser JavaScript console output

Screenshots or screencasts of the bug in action

  • [ x ] I may be interested in making a pull request to address this
@wilsonnater
Copy link
Author

For anyone else reading this, a quick work around is checking if the notification is None.

notification = pn.state.notifications
if notification is not None:
    notifications.error('This is an error notification.', duration=1000)

@wilsonnater wilsonnater changed the title Typing error on panel.state.notifications.error Typing error on panel.state.notifications.error based on examples May 11, 2024
@wilsonnater
Copy link
Author

This seems like it is connected or related to some other issues with notifications. #6184

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant