Skip to content

Commit 87385a9

Browse files
committed
Refactors deprecated_types to deprecated_components
- Checks for namespace on top of the type - Modifies warning message - Modifies test to capture new warning message
1 parent c54ae91 commit 87385a9

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

Diff for: components/dash-core-components/tests/integration/location/test_location_logout.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def _insert_cookie(rep):
4242

4343
with pytest.warns(
4444
DeprecationWarning,
45-
match="LogoutButton is deprecated, use a different component type instead",
45+
match="The Logout Button is no longer used with Dash Enterprise and can be replaced with a html.Button or html.A.",
4646
):
4747
dash_dcc.start_server(app)
4848
time.sleep(1)

Diff for: dash/_validate.py

+14-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
from collections import defaultdict
23
from collections.abc import MutableSequence
34
import re
45
import warnings
@@ -424,13 +425,19 @@ def validate_layout(layout, layout_value):
424425

425426
def _validate(value):
426427
def _validate_type(comp):
427-
deprecated_types = ["LogoutButton"]
428-
component_type = getattr(comp, "_type", None)
429-
if component_type and component_type in deprecated_types:
430-
warnings.warn(
431-
f"{component_type} is deprecated, use a different component type instead",
432-
DeprecationWarning,
433-
)
428+
deprecated_components = defaultdict(lambda: defaultdict(dict))
429+
deprecated_components["dash_core_components"][
430+
"LogoutButton"
431+
] = """
432+
The Logout Button is no longer used with Dash Enterprise and can be replaced with a html.Button or html.A.
433+
eg: html.A(href=os.getenv('DASH_LOGOUT_URL'))
434+
"""
435+
436+
_type = getattr(comp, "_type", "")
437+
_ns = getattr(comp, "_namespace", "")
438+
deprecation_message = deprecated_components[_ns][_type]
439+
if deprecation_message:
440+
warnings.warn(dedent(deprecation_message), DeprecationWarning)
434441

435442
def _validate_id(comp):
436443
component_id = stringify_id(getattr(comp, "id", None))

0 commit comments

Comments
 (0)