Skip to content

Commit ca37382

Browse files
committed
swapping graph_objs and graph_objects
1 parent 57d923c commit ca37382

File tree

2,625 files changed

+433673
-433586
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,625 files changed

+433673
-433586
lines changed

_plotly_utils/basevalidators.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2370,26 +2370,26 @@ def __init__(self, plotly_name, parent_name, data_class_str, data_docs, **kwargs
23702370
@staticmethod
23712371
def compute_graph_obj_module_str(data_class_str, parent_name):
23722372
if parent_name == "frame" and data_class_str in ["Data", "Layout"]:
2373-
# Special case. There are no graph_objs.frame.Data or
2374-
# graph_objs.frame.Layout classes. These are remapped to
2375-
# graph_objs.Data and graph_objs.Layout
2373+
# Special case. There are no graph_objects.frame.Data or
2374+
# graph_objects.frame.Layout classes. These are remapped to
2375+
# graph_objects.Data and graph_objects.Layout
23762376

23772377
parent_parts = parent_name.split(".")
2378-
module_str = ".".join(["plotly.graph_objs"] + parent_parts[1:])
2378+
module_str = ".".join(["plotly.graph_objects"] + parent_parts[1:])
23792379
elif parent_name == "layout.template" and data_class_str == "Layout":
23802380
# Remap template's layout to regular layout
2381-
module_str = "plotly.graph_objs"
2381+
module_str = "plotly.graph_objects"
23822382
elif "layout.template.data" in parent_name:
23832383
# Remap template's traces to regular traces
23842384
parent_name = parent_name.replace("layout.template.data.", "")
23852385
if parent_name:
2386-
module_str = "plotly.graph_objs." + parent_name
2386+
module_str = "plotly.graph_objects." + parent_name
23872387
else:
2388-
module_str = "plotly.graph_objs"
2388+
module_str = "plotly.graph_objects"
23892389
elif parent_name:
2390-
module_str = "plotly.graph_objs." + parent_name
2390+
module_str = "plotly.graph_objects." + parent_name
23912391
else:
2392-
module_str = "plotly.graph_objs"
2392+
module_str = "plotly.graph_objects"
23932393

23942394
return module_str
23952395

@@ -2580,7 +2580,7 @@ def description(self):
25802580
def get_trace_class(self, trace_name):
25812581
# Import trace classes
25822582
if trace_name not in self._class_map:
2583-
trace_module = import_module("plotly.graph_objs")
2583+
trace_module = import_module("plotly.graph_objects")
25842584
trace_class_name = self.class_strs_map[trace_name]
25852585
self._class_map[trace_name] = getattr(trace_module, trace_class_name)
25862586

@@ -2591,7 +2591,7 @@ def validate_coerce(self, v, skip_invalid=False, _validate=True):
25912591

25922592
# Import Histogram2dcontour, this is the deprecated name of the
25932593
# Histogram2dContour trace.
2594-
from plotly.graph_objs import Histogram2dcontour
2594+
from plotly.graph_objects import Histogram2dcontour
25952595

25962596
if v is None:
25972597
v = []

bin/codegen/__init__.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from codegen.datatypes import build_datatype_py, write_datatype_py # noqa: F401
77
from codegen.compatibility import (
88
write_deprecated_datatypes,
9-
write_graph_objs_graph_objs,
9+
write_graph_objects_graph_objects,
1010
DEPRECATED_DATATYPES,
1111
)
1212
from codegen.figure import write_figure_classes
@@ -60,7 +60,7 @@ def preprocess_schema(plotly_schema):
6060
matching the structure of `figure.layout` and `traceTemplate` is a dict
6161
matching the structure of the trace with type `trace_type` (e.g. 'scatter').
6262
Alternatively, this may be specified as an instance of
63-
plotly.graph_objs.layout.Template.
63+
plotly.graph_objects.layout.Template.
6464
6565
Trace templates are applied cyclically to
6666
traces of each type. Container arrays (eg `annotations`) have special
@@ -89,22 +89,22 @@ def make_paths(codedir):
8989
"""Make various paths needed for code generation."""
9090

9191
validators_dir = codedir / "validators"
92-
graph_objs_dir = codedir / "graph_objs"
93-
graph_objects_path = codedir / "graph_objects" / "__init__.py"
94-
return validators_dir, graph_objs_dir, graph_objects_path
92+
graph_objects_dir = codedir / "graph_objects"
93+
graph_objs_path = codedir / "graph_objs" / "__init__.py"
94+
return validators_dir, graph_objects_dir, graph_objs_path
9595

9696

9797
def perform_codegen(codedir, noformat=False):
9898
"""Generate code."""
9999

100100
# Get paths
101-
validators_dir, graph_objs_dir, graph_objects_path = make_paths(codedir)
101+
validators_dir, graph_objects_dir, graph_objs_path = make_paths(codedir)
102102

103103
# Delete prior codegen output
104104
if validators_dir.exists():
105105
shutil.rmtree(validators_dir)
106-
if graph_objs_dir.exists():
107-
shutil.rmtree(graph_objs_dir)
106+
if graph_objects_dir.exists():
107+
shutil.rmtree(graph_objects_dir)
108108

109109
# Load plotly schema
110110
project_root = codedir.parent
@@ -186,10 +186,10 @@ def perform_codegen(codedir, noformat=False):
186186
write_datatype_py(codedir, node)
187187

188188
# Deprecated
189-
# These are deprecated legacy datatypes like graph_objs.Marker
189+
# These are deprecated legacy datatypes like graph_objects.Marker
190190
write_deprecated_datatypes(codedir)
191191

192-
# Write figure class to graph_objs
192+
# Write figure class to graph_objects
193193
data_validator = get_data_validator_instance(base_traces_node)
194194
layout_validator = layout_node.get_validator_instance()
195195
frame_validator = frame_node.get_validator_instance()
@@ -222,10 +222,10 @@ def perform_codegen(codedir, noformat=False):
222222
f".{node.name_undercase}"
223223
)
224224

225-
# Write plotly/graph_objs/graph_objs.py
225+
# Write plotly/graph_objects/graph_objects.py
226226
# This is for backward compatibility. It just imports everything from
227-
# graph_objs/__init__.py
228-
write_graph_objs_graph_objs(codedir)
227+
# graph_objects/__init__.py
228+
write_graph_objects_graph_objects(codedir)
229229

230230
# Add Figure and FigureWidget
231231
root_datatype_imports = datatype_rel_class_imports[()]
@@ -241,7 +241,7 @@ def perform_codegen(codedir, noformat=False):
241241
import ipywidgets as _ipywidgets
242242
from packaging.version import Version as _Version
243243
if _Version(_ipywidgets.__version__) >= _Version("7.0.0"):
244-
from ..graph_objs._figurewidget import FigureWidget
244+
from ..graph_objects._figurewidget import FigureWidget
245245
else:
246246
raise ImportError()
247247
except Exception:
@@ -255,7 +255,7 @@ def __getattr__(import_name):
255255
import ipywidgets
256256
from packaging.version import Version
257257
if Version(ipywidgets.__version__) >= Version("7.0.0"):
258-
from ..graph_objs._figurewidget import FigureWidget
258+
from ..graph_objects._figurewidget import FigureWidget
259259
return FigureWidget
260260
else:
261261
raise ImportError()
@@ -270,43 +270,43 @@ def __getattr__(import_name):
270270
# __all__
271271
for path_parts, class_names in alls.items():
272272
if path_parts and class_names:
273-
filepath = codedir / "graph_objs"
273+
filepath = codedir / "graph_objects"
274274
filepath = filepath.joinpath(*path_parts) / "__init__.py"
275275
with open(filepath, "at") as f:
276276
f.write(f"\n__all__ = {class_names}")
277277

278278
# Output datatype __init__.py files
279-
graph_objs_pkg = codedir / "graph_objs"
279+
graph_objects_pkg = codedir / "graph_objects"
280280
for path_parts in datatype_rel_class_imports:
281281
rel_classes = sorted(datatype_rel_class_imports[path_parts])
282282
rel_modules = sorted(datatype_rel_module_imports.get(path_parts, []))
283283
if path_parts == ():
284284
init_extra = optional_figure_widget_import
285285
else:
286286
init_extra = ""
287-
write_init_py(graph_objs_pkg, path_parts, rel_modules, rel_classes, init_extra)
287+
write_init_py(graph_objects_pkg, path_parts, rel_modules, rel_classes, init_extra)
288288

289-
# Output graph_objects.py alias
290-
graph_objects_rel_classes = [
291-
"..graph_objs." + rel_path.split(".")[-1]
289+
# Output graph_objs.py alias
290+
graph_objs_rel_classes = [
291+
"..graph_objects." + rel_path.split(".")[-1]
292292
for rel_path in datatype_rel_class_imports[()]
293293
]
294-
graph_objects_rel_modules = [
295-
"..graph_objs." + rel_module.split(".")[-1]
294+
graph_objs_rel_modules = [
295+
"..graph_objects." + rel_module.split(".")[-1]
296296
for rel_module in datatype_rel_module_imports[()]
297297
]
298298

299-
graph_objects_init_source = build_from_imports_py(
300-
graph_objects_rel_modules,
301-
graph_objects_rel_classes,
299+
graph_objs_init_source = build_from_imports_py(
300+
graph_objs_rel_modules,
301+
graph_objs_rel_classes,
302302
init_extra=optional_figure_widget_import,
303303
)
304-
graph_objects_path = codedir / "graph_objects"
305-
graph_objects_path.mkdir(parents=True, exist_ok=True)
306-
graph_objects_path /= "__init__.py"
307-
with open(graph_objects_path, "wt") as f:
304+
graph_objs_path = codedir / "graph_objs"
305+
graph_objs_path.mkdir(parents=True, exist_ok=True)
306+
graph_objs_path /= "__init__.py"
307+
with open(graph_objs_path, "wt") as f:
308308
f.write("# ruff: noqa: F401\n")
309-
f.write(graph_objects_init_source)
309+
f.write(graph_objs_init_source)
310310

311311

312312
if __name__ == "__main__":

bin/codegen/compatibility.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
def build_deprecated_datatypes_py():
4444
"""
45-
Build datatype (graph_objs) class source code string for deprecated
45+
Build datatype (graph_objects) class source code string for deprecated
4646
datatypes
4747
4848
Returns
@@ -57,7 +57,7 @@ def build_deprecated_datatypes_py():
5757
buffer.write(
5858
r"""
5959
warnings.filterwarnings("default",
60-
r"plotly\.graph_objs\.\w+ is deprecated",
60+
r"plotly\.graph_objects\.\w+ is deprecated",
6161
DeprecationWarning)
6262
6363
@@ -100,15 +100,15 @@ def build_deprecation_message(class_name, base_type, new):
100100
new: list of str
101101
List of replacements that users should use instead.
102102
Replacements may be:
103-
- A package string relative to plotly.graph_objs. In this case the
103+
- A package string relative to plotly.graph_objects. In this case the
104104
replacement class is assumed to be named `class_name`.
105105
e.g. `new` == ['layout`] and `class_name` == 'XAxis` corresponds
106-
to the 'plotly.graph_objs.layout.XAxis' class
106+
to the 'plotly.graph_objects.layout.XAxis' class
107107
- String containing the package and class. The string is
108108
identified as containing a class name if the final name in the
109109
package string begins with an uppercase letter.
110110
e.g. `new` == ['Scatter'] corresponds to the
111-
['plotly.graph_objs.Scatter'] class.
111+
['plotly.graph_objects.Scatter'] class.
112112
- The literal string 'etc.'. This string is not interpreted as a
113113
package or class and is displayed to the user as-is to
114114
indicate that the list of replacement classes is not complete.
@@ -129,21 +129,21 @@ def build_deprecation_message(class_name, base_type, new):
129129
if not repl_is_class:
130130
repl_parts.append(class_name)
131131

132-
# Add plotly.graph_objs prefix
133-
full_class_str = ".".join(["plotly", "graph_objs"] + repl_parts)
132+
# Add plotly.graph_objects prefix
133+
full_class_str = ".".join(["plotly", "graph_objects"] + repl_parts)
134134
replacements.append(full_class_str)
135135

136136
replacemens_str = "\n - ".join(replacements)
137137

138138
if base_type is list:
139139
return f"""\
140-
plotly.graph_objs.{class_name} is deprecated.
140+
plotly.graph_objects.{class_name} is deprecated.
141141
Please replace it with a list or tuple of instances of the following types
142142
- {replacemens_str}
143143
"""
144144
else:
145145
return f"""\
146-
plotly.graph_objs.{class_name} is deprecated.
146+
plotly.graph_objects.{class_name} is deprecated.
147147
Please replace it with one of the following more specific types
148148
- {replacemens_str}
149149
"""
@@ -157,42 +157,42 @@ def write_deprecated_datatypes(codedir):
157157
Parameters
158158
----------
159159
codedir :
160-
Root directory in which the graph_objs package should reside
160+
Root directory in which the graph_objects package should reside
161161
162162
Returns
163163
-------
164164
None
165165
"""
166166
# Generate source code
167167
datatype_source = build_deprecated_datatypes_py()
168-
filepath = codedir / "graph_objs" / "_deprecations.py"
168+
filepath = codedir / "graph_objects" / "_deprecations.py"
169169

170170
# Write file
171171
write_source_py(datatype_source, filepath)
172172

173173

174-
def write_graph_objs_graph_objs(codedir):
174+
def write_graph_objects_graph_objects(codedir):
175175
"""
176-
Write the plotly/graph_objs/graph_objs.py file
176+
Write the plotly/graph_objects/graph_objects.py file
177177
178-
This module just imports everything from the plotly.graph_objs package.
178+
This module just imports everything from the plotly.graph_objects package.
179179
We write it for backward compatibility with legacy imports like:
180180
181-
from plotly.graph_objs import graph_objs
181+
from plotly.graph_objects import graph_objects
182182
183183
Parameters
184184
----------
185185
codedir : str
186-
Root directory in which the graph_objs package should reside
186+
Root directory in which the graph_objects package should reside
187187
188188
Returns
189189
-------
190190
None
191191
"""
192-
filepath = codedir / "graph_objs" / "graph_objs.py"
192+
filepath = codedir / "graph_objects" / "graph_objects.py"
193193
with open(filepath, "wt") as f:
194194
f.write(
195195
"""\
196-
from plotly.graph_objs import *
196+
from plotly.graph_objects import *
197197
"""
198198
)

bin/codegen/datatypes.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def get_typing_type(plotly_type, array_ok=False):
5353

5454
def build_datatype_py(node):
5555
"""
56-
Build datatype (graph_objs) class source code string for a datatype
56+
Build datatype (graph_objects) class source code string for a datatype
5757
PlotlyNode
5858
5959
Parameters
@@ -73,14 +73,14 @@ def build_datatype_py(node):
7373
# Handle template traces
7474
#
7575
# We want template trace/layout classes like
76-
# plotly.graph_objs.layout.template.data.Scatter to map to the
77-
# corresponding trace/layout class (e.g. plotly.graph_objs.Scatter).
76+
# plotly.graph_objects.layout.template.data.Scatter to map to the
77+
# corresponding trace/layout class (e.g. plotly.graph_objects.Scatter).
7878
# So rather than generate a class definition, we just import the
7979
# corresponding trace/layout class
8080
if node.parent_path_str == "layout.template.data":
81-
return f"from plotly.graph_objs import {node.name_datatype_class}"
81+
return f"from plotly.graph_objects import {node.name_datatype_class}"
8282
elif node.path_str == "layout.template.layout":
83-
return "from plotly.graph_objs import Layout"
83+
return "from plotly.graph_objects import Layout"
8484

8585
# Extract node properties
8686
datatype_class = node.name_datatype_class
@@ -175,13 +175,13 @@ def _subplot_re_match(self, prop):
175175
for subtype_node in subtype_nodes:
176176
if subtype_node.is_array_element:
177177
prop_type = (
178-
f"tuple[plotly.graph_objs{node.dotpath_str}."
178+
f"tuple[plotly.graph_objects{node.dotpath_str}."
179179
+ f"{subtype_node.name_datatype_class}]"
180180
)
181181

182182
elif subtype_node.is_compound:
183183
prop_type = (
184-
f"plotly.graph_objs{node.dotpath_str}."
184+
f"plotly.graph_objects{node.dotpath_str}."
185185
+ f"{subtype_node.name_datatype_class}"
186186
)
187187

@@ -291,7 +291,7 @@ def __init__(self"""
291291
# Constructor Docstring
292292
header = f"Construct a new {datatype_class} object"
293293
class_name = (
294-
f"plotly.graph_objs{node.parent_dotpath_str}.{node.name_datatype_class}"
294+
f"plotly.graph_objects{node.parent_dotpath_str}.{node.name_datatype_class}"
295295
)
296296

297297
extras = [
@@ -582,12 +582,12 @@ def add_docstring(
582582

583583
def write_datatype_py(outdir, node):
584584
"""
585-
Build datatype (graph_objs) class source code and write to a file
585+
Build datatype (graph_objects) class source code and write to a file
586586
587587
Parameters
588588
----------
589589
outdir :
590-
Root outdir in which the graph_objs package should reside
590+
Root outdir in which the graph_objects package should reside
591591
node :
592592
The datatype node (node.is_datatype must evaluate to true) for which
593593
to build the datatype class
@@ -597,6 +597,6 @@ def write_datatype_py(outdir, node):
597597
None
598598
"""
599599

600-
filepath = (outdir / "graph_objs").joinpath(*node.parent_path_parts) / f"_{node.name_undercase}.py"
600+
filepath = (outdir / "graph_objects").joinpath(*node.parent_path_parts) / f"_{node.name_undercase}.py"
601601
datatype_source = build_datatype_py(node)
602602
write_source_py(datatype_source, filepath, leading_newlines=2)

0 commit comments

Comments
 (0)