-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Deprecate LogoutButton #2899
Deprecate LogoutButton #2899
Changes from 3 commits
1b3f328
d6e1b58
c54ae91
87385a9
3b0ab61
6bd822e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import sys | ||
from collections.abc import MutableSequence | ||
import re | ||
import warnings | ||
from textwrap import dedent | ||
from keyword import iskeyword | ||
import flask | ||
|
@@ -422,6 +423,15 @@ def validate_layout(layout, layout_value): | |
component_ids = set() | ||
|
||
def _validate(value): | ||
def _validate_type(comp): | ||
deprecated_types = ["LogoutButton"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to make sure there is no collision, we should also check the I would refactor the
The for the check you could have:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed in 87385a9 |
||
component_type = getattr(comp, "_type", None) | ||
if component_type and component_type in deprecated_types: | ||
warnings.warn( | ||
f"{component_type} is deprecated, use a different component type instead", | ||
DeprecationWarning, | ||
) | ||
|
||
def _validate_id(comp): | ||
component_id = stringify_id(getattr(comp, "id", None)) | ||
if component_id and component_id in component_ids: | ||
|
@@ -432,9 +442,11 @@ def _validate_id(comp): | |
) | ||
component_ids.add(component_id) | ||
|
||
_validate_type(value) | ||
_validate_id(value) | ||
|
||
for component in value._traverse(): # pylint: disable=protected-access | ||
_validate_type(component) | ||
_validate_id(component) | ||
|
||
if isinstance(layout_value, (list, tuple)): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add a condition
if add_initial_logout_button
for testing the deprecation notice otherwise it fails. Maybe better to just test the deprecation notice in a new test.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. My worry is that
DeprecationWarning
is not being output when theLogoutButton
is being used inside a callback—only when theLogoutButton
is defined inapp.layout
.This is the reason I was checking for the warning in the two separate scenarios. However, if we don't need to output a
DeprecationWarning
when theLogoutButton
is used inside a callback, then I can just create a new test.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leeagustin can you please let us know if you added or are interested in adding the new test? thanks - @gvwilson