Skip to content

Commit dd7cdd4

Browse files
David-Wu1119claude
andcommitted
Use f-strings and drop the tests and changelog entry
Per review: format the two messages with f-strings instead of str.format(), and remove the added tests and CHANGELOG entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent e797522 commit dd7cdd4

5 files changed

Lines changed: 5 additions & 20 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55
## Unreleased
66

77
### Fixed
8-
- Fix the error messages for adding a `secondary_y` trace to a subplot created without the `secondary_y` spec, and for an invalid `output_type` in `plotly.io.from_json`/`read_json`, which showed unformatted placeholders such as `{subplot_type}` and `({row}, {col})` [[#5772](https://github.com/plotly/plotly.py/pull/5772)], with thanks to @David-Wu1119 for the contribution!
98
- Fix concurrent first access to lazily initialized graph object properties, which could raise `ValueError("Invalid value")` [[#3441](https://github.com/plotly/plotly.py/issues/3441)], with thanks to @hb1915 for the contribution!
109
- Fix `px.sunburst`, `px.treemap` and `px.icicle` listing sectors in a different order on every run when `path` is used with a Polars DataFrame; sectors now follow their order of first appearance for all dataframe backends [[#5765](https://github.com/plotly/plotly.py/issues/5765)], with thanks to @Irahan2 for the contribution!
1110

‎plotly/_subplots.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,11 +1421,11 @@ def _set_trace_grid_reference(trace, layout, grid_ref, row, col, secondary_y=Fal
14211421
if secondary_y:
14221422
if len(subplot_refs) < 2:
14231423
raise ValueError(
1424-
"""
1425-
Subplot with type '{subplot_type}' at grid position ({row}, {col}) was not
1424+
f"""
1425+
Subplot with type '{subplot_refs[0].subplot_type}' at grid position ({row}, {col}) was not
14261426
created with the secondary_y spec property set to True. See the docstring
14271427
for the specs argument to plotly.subplots.make_subplots for more information.
1428-
""".format(subplot_type=subplot_refs[0].subplot_type, row=row, col=col)
1428+
"""
14291429
)
14301430
trace_kwargs = subplot_refs[1].trace_kwargs
14311431
else:

‎plotly/io/_utils.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ def validate_coerce_output_type(output_type):
3636
cls = go.FigureWidget
3737
else:
3838
raise ValueError(
39-
"""
39+
f"""
4040
Invalid output type: {output_type}
41-
Must be one of: 'Figure', 'FigureWidget'""".format(output_type=output_type)
41+
Must be one of: 'Figure', 'FigureWidget'"""
4242
)
4343
return cls
4444

‎tests/test_core/test_subplots/test_make_subplots.py‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2038,12 +2038,3 @@ def test_make_subplots_spacing_error():
20382038
ValueError, match=r"^Vertical spacing must be between 0 and 1\.$"
20392039
):
20402040
subplots.make_subplots(1, 1, vertical_spacing=1.01)
2041-
2042-
2043-
def test_secondary_y_without_spec_error():
2044-
fig = subplots.make_subplots(rows=1, cols=2)
2045-
with pytest.raises(
2046-
ValueError,
2047-
match=r"Subplot with type 'xy' at grid position \(1, 2\) was not",
2048-
):
2049-
fig.add_scatter(x=[1], y=[1], row=1, col=2, secondary_y=True)

‎tests/test_io/test_to_from_json.py‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,6 @@ def test_from_json_invalid(fig1):
118118
pio.from_json(bad_json)
119119

120120

121-
def test_from_json_invalid_output_type(fig1):
122-
with pytest.raises(ValueError, match="Invalid output type: Bogus"):
123-
pio.from_json(pio.to_json(fig1), output_type="Bogus")
124-
125-
126121
def test_from_json_skip_invalid(fig1):
127122
dict1 = fig1.to_dict()
128123

0 commit comments

Comments
 (0)