8000 switch to ruff by gvwilson · Pull Request #5218 · plotly/plotly.py · GitHub
[go: up one dir, main page]

Skip to content

switch to ruff #5218

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 4 commits into from
Jun 19, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: corrections based on code review from @emilykl
- Run `ruff format --check .` instead of `ruff format .` in Circle CI.
- Use `base_type is list` instead of `base_type == list`.
- Remove commented-out lines of code.
- Remove unnecessary parentheses around some strings.
- Be more consistent about (re-)naming test functions that had duplicated names.
- Use `noqa: F401` to suppress `ruff check` complaint about unused import.
  • Loading branch information
gvwilson committed Jun 13, 2025
commit 4a1a814a00710cc51130edf9a6d44e3f9ae5593b
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ jobs:
name: Check handwritten code with ruff
command: |
source .venv/bin/activate
ruff format .
ruff format --check .

test_core_py:
parameters:
Expand Down
2 changes: 1 addition & 1 deletion codegen/compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def build_deprecation_message(class_name, base_type, new):

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

if isinstance(base_type, list):
if base_type is list:
return f"""\
plotly.graph_objs.{class_name} is deprecated.
Please replace it with a list or tuple of instances of the following types
Expand Down
7 changes: 1 addition & 6 deletions plotly/figure_factory/_ternary_contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,6 @@ def _compute_grid(coordinates, values, interp_mode="ilr"):
grid_z = scipy_interp.griddata(
coord_points[:2].T, values, (grid_x, grid_y), method="cubic"
)
# grid_z_other = scipy_interp.griddata(
# coord_points[:2].T, values, (grid_x, grid_y), method="nearest"
# )
# mask_nan = np.isnan(grid_z)
# grid_z[mask_nan] = grid_z_other[mask_nan]
return grid_z, gr_x, gr_y


Expand Down Expand Up @@ -439,7 +434,7 @@ def _contour_trace(
else:
colors = [linecolor] * ncontours

# Retrieve all contours
# Retrieve all contours
all_contours, all_values, all_areas, all_colors = _extract_contours(
z, values, colors
)
Expand Down
2 changes: 1 addition & 1 deletion plotly/io/_orca.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ def mathjax(self):
"""
return self._props.get(
"mathjax",
("https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js"),
"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js",
)

@mathjax.setter
Expand Down
8 changes: 4 additions & 4 deletions tests/test_core/test_graph_objs/test_figure_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,19 @@ def test_property_assignment_dots(self):
self.figure["frames[0].layout.yaxis.title.text"] = "f2"
self.assertEqual(self.figure["frames.0.layout.yaxis.title.text"], "f2")

def test_access_invalid_attr_1(self):
def test_access_invalid_attr(self):
with pytest.raises(AttributeError):
self.figure.bogus

def test_access_invalid_item_1(self):
def test_access_invalid_item(self):
with pytest.raises(KeyError):
self.figure["bogus"]

def test_assign_invalid_attr_2(self):
def test_assign_invalid_attr(self):
with pytest.raises(AttributeError):
self.figure.bogus = "val"

def test_access_invalid_item_2(self):
def test_assign_invalid_item(self):
with pytest.raises(KeyError):
self.figure["bogus"] = "val"

Expand Down
4 changes: 2 additions & 2 deletions tests/test_core/test_offline/test_offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def test_including_plotlyjs_directory_div(self):

def test_including_plotlyjs_path_html(self):
for include_plotlyjs in [
("https://cdnjs.cloudflare.com/ajax/libs/plotly.js/1.40.1/plotly.min.js"),
"https://cdnjs.cloudflare.com/ajax/libs/plotly.js/1.40.1/plotly.min.js",
"subpath/to/plotly.min.js",
"something.js",
]:
Expand All @@ -259,7 +259,7 @@ def test_including_plotlyjs_path_html(self):

def test_including_plotlyjs_path_div(self):
for include_plotlyjs in [
("https://cdnjs.cloudflare.com/ajax/libs/plotly.js/1.40.1/plotly.min.js"),
"https://cdnjs.cloudflare.com/ajax/libs/plotly.js/1.40.1/plotly.min.js",
"subpath/to/plotly.min.js",
"something.js",
]:
Expand Down
4 changes: 1 addition & 3 deletions tests/test_io/test_renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,7 @@ def webbrowser_absent_import(name, globals, locals, fromlist, level):
with mock.patch("builtins.__import__", webbrowser_absent_import):
# 1: check whether importing webbrowser actually results in an ImportError
with pytest.raises(ImportError):
import webbrowser as wb

assert wb
import webbrowser # noqa: F401

# 2: check whether the _repr_html_ can handle it regardless
fig1._repr_html_()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def test_rejection_values(val, validator_values):
with pytest.raises(ValueError) as validation_failure:
validator_values.validate_coerce(val)

assert "Invalid value".format() in str(validation_failure.value)
assert "Invalid value" in str(validation_failure.value)
assert "['foo', 'BAR', '']" in str(validation_failure.value)


Expand Down
0