Skip to content

Commit f4a005d

Browse files
author
Joseph Damiba
authored
Merge pull request #2183 from plotly/px-permissive-defaults
prevent the creation of new px.default properties at run time
2 parents 9fb88c1 + bdda851 commit f4a005d

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Diff for: packages/python/plotly/plotly/express/_core.py

+11
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@
1616

1717

1818
class PxDefaults(object):
19+
__slots__ = [
20+
"template",
21+
"width",
22+
"height",
23+
"color_discrete_sequence",
24+
"color_continuous_scale",
25+
"symbol_sequence",
26+
"line_dash_sequence",
27+
"size_max",
28+
]
29+
1930
def __init__(self):
2031
self.template = None
2132
self.width = None

Diff for: packages/python/plotly/plotly/tests/test_core/test_px/test_px.py

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import plotly.express as px
22
import numpy as np
3+
import pytest
34

45

56
def test_scatter():
@@ -232,3 +233,9 @@ def assert_orderings(days_order, days_check, times_order, times_check):
232233
for days in permutations(df["day"].unique()):
233234
for times in permutations(df["time"].unique()):
234235
assert_orderings(days, days, times, times)
236+
237+
238+
def test_permissive_defaults():
239+
msg = "'PxDefaults' object has no attribute 'should_not_work'"
240+
with pytest.raises(AttributeError, match=msg):
241+
px.defaults.should_not_work = "test"

0 commit comments

Comments
 (0)