Skip to content

prevent the creation of new px.default properties at run time #2183

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

Merged
merged 7 commits into from
Feb 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/python/plotly/plotly/express/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import plotly.express as px
import numpy as np
import pytest


def test_scatter():
Expand Down Expand Up @@ -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"