Skip to content

Commit ed874a2

Browse files
committed
more work to satisfy ruff
1 parent c489a1f commit ed874a2

File tree

15 files changed

+42
-46
lines changed

15 files changed

+42
-46
lines changed

_plotly_utils/basevalidators.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import io
88
import re
99
import sys
10-
import warnings
1110
import narwhals.stable.v1 as nw
1211

1312
from _plotly_utils.optional_imports import get_module

_plotly_utils/colors/qualitative.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def swatches(template=None):
151151
Plotly_r = Plotly[::-1]
152152
T10_r = T10[::-1]
153153

154-
from .colorbrewer import ( # noqa: F401
154+
from .colorbrewer import ( # noqa: E402 F401
155155
Set1,
156156
Pastel1,
157157
Dark2,
@@ -165,7 +165,7 @@ def swatches(template=None):
165165
Pastel2_r,
166166
Set3_r,
167167
)
168-
from .carto import ( # noqa: F401
168+
from .carto import ( # noqa: E402 F401
169169
Antique,
170170
Bold,
171171
Pastel,

_plotly_utils/colors/sequential.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def swatches_continuous(template=None):
124124
Turbo_r = Turbo[::-1]
125125
Viridis_r = Viridis[::-1]
126126

127-
from .plotlyjs import ( # noqa: F401
127+
from .plotlyjs import ( # noqa: E402 F401
128128
Blackbody,
129129
Bluered,
130130
Electric,
@@ -139,7 +139,7 @@ def swatches_continuous(template=None):
139139
Rainbow_r,
140140
)
141141

142-
from .colorbrewer import ( # noqa: F401
142+
from .colorbrewer import ( # noqa: E402 F401
143143
Blues,
144144
BuGn,
145145
BuPu,
@@ -180,7 +180,7 @@ def swatches_continuous(template=None):
180180
YlOrRd_r,
181181
)
182182

183-
from .cmocean import ( # noqa: F401
183+
from .cmocean import ( # noqa: E402 F401
184184
turbid,
185185
thermal,
186186
haline,
@@ -209,7 +209,7 @@ def swatches_continuous(template=None):
209209
tempo_r,
210210
)
211211

212-
from .carto import ( # noqa: F401
212+
from .carto import ( # noqa: E402 F401
213213
Burg,
214214
Burgyl,
215215
Redor,

_plotly_utils/png.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ def write_array(self, outfile, pixels):
842842
"""
843843

844844
if self.interlace:
845-
if type(pixels) != array:
845+
if not isarray(pixels):
846846
# Coerce to array type
847847
fmt = "BH"[self.bitdepth > 8]
848848
pixels = array(fmt, pixels)

_plotly_utils/utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -469,12 +469,12 @@ def display_string_positions(p, i=None, offset=0, length=1, char="^", trim=True)
469469
maxaddr = 0
470470
if i is None:
471471
for p_ in p:
472-
for l in range(length):
473-
maxaddr = p_ + offset + l
472+
for temp in range(length):
473+
maxaddr = p_ + offset + temp
474474
s[maxaddr] = char
475475
else:
476-
for l in range(length):
477-
maxaddr = p[i] + offset + l
476+
for temp in range(length):
477+
maxaddr = p[i] + offset + temp
478478
s[maxaddr] = char
479479
ret = "".join(s)
480480
if trim:
@@ -501,8 +501,8 @@ def chomp_empty_strings(strings, c, reverse=False):
501501
on the right or "" if it is the last string.
502502
"""
503503

504-
def _rev(l):
505-
return [s[::-1] for s in l][::-1]
504+
def _rev(vals):
505+
return [s[::-1] for s in vals][::-1]
506506

507507
if reverse:
508508
return _rev(chomp_empty_strings(_rev(strings), c))

codegen/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,10 @@ def __getattr__(import_name):
322322
graph_objects_path = opath.join(outdir, "graph_objects", "__init__.py")
323323
os.makedirs(opath.join(outdir, "graph_objects"), exist_ok=True)
324324
with open(graph_objects_path, "wt") as f:
325+
f.write("# ruff: noqa: F401\n")
325326
f.write(graph_objects_init_source)
326327

327-
# Run black code formatter on output directories
328+
# Run code formatter on output directories
328329
if noformat:
329330
print("skipping reformatting")
330331
else:

plotly/basedatatypes.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ def _len_dict_item(item):
3636
convert to a string before calling len on it.
3737
"""
3838
try:
39-
l = len(item)
39+
temp = len(item)
4040
except TypeError:
4141
try:
42-
l = len("%d" % (item,))
42+
temp = len("%d" % (item,))
4343
except TypeError:
4444
raise ValueError(
4545
"Cannot find string length of an item that is not string-like nor an integer."
4646
)
47-
return l
47+
return temp
4848

4949

5050
def _str_to_dict_path_full(key_path_str):
@@ -105,7 +105,7 @@ def _split_and_chomp(s):
105105
# the list ("lift" the items out of the sublists)
106106
key_path2c = list(
107107
reduce(
108-
lambda x, y: x + y if type(y) == type(list()) else x + [y],
108+
lambda x, y: x + y if isinstance(y, list) else x + [y],
109109
map(_split_and_chomp, key_path2b),
110110
[],
111111
)
@@ -140,7 +140,7 @@ def _remake_path_from_tuple(props):
140140
return ""
141141

142142
def _add_square_brackets_to_number(n):
143-
if type(n) == type(int()):
143+
if isinstance(n, int):
144144
return "[%d]" % (n,)
145145
return n
146146

plotly/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from _plotly_utils.exceptions import *
1+
from _plotly_utils.exceptions import PlotlyError # noqa: F401

plotly/files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from _plotly_utils.files import *
1+
from _plotly_utils.files import PLOTLY_DIR, ensure_writable_plotly_dir # noqa: F401

plotly/graph_objects/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# ruff: noqa: F401
12
import sys
23
from typing import TYPE_CHECKING
34

0 commit comments

Comments
 (0)