diff --git a/packages/python/plotly/plotly/express/_core.py b/packages/python/plotly/plotly/express/_core.py index db8f002c2c1..1f9e2706af7 100644 --- a/packages/python/plotly/plotly/express/_core.py +++ b/packages/python/plotly/plotly/express/_core.py @@ -16,6 +16,17 @@ class PxDefaults(object): + __slots__ = [ + "template", + "width", + "height", + "color_discrete_sequence", + "color_continuous_scale", + "symbol_sequence", + "line_dash_sequence", + "size_max", + ] + def __init__(self): self.template = None self.width = None diff --git a/packages/python/plotly/plotly/tests/test_core/test_px/test_px.py b/packages/python/plotly/plotly/tests/test_core/test_px/test_px.py index 9ace6a7b4a9..b4880899e95 100644 --- a/packages/python/plotly/plotly/tests/test_core/test_px/test_px.py +++ b/packages/python/plotly/plotly/tests/test_core/test_px/test_px.py @@ -1,5 +1,6 @@ import plotly.express as px import numpy as np +import pytest def test_scatter(): @@ -232,3 +233,9 @@ def assert_orderings(days_order, days_check, times_order, times_check): for days in permutations(df["day"].unique()): for times in permutations(df["time"].unique()): assert_orderings(days, days, times, times) + + +def test_permissive_defaults(): + msg = "'PxDefaults' object has no attribute 'should_not_work'" + with pytest.raises(AttributeError, match=msg): + px.defaults.should_not_work = "test"