Skip to content

Commit 43e3a40

Browse files
switch to black .22
1 parent 6980216 commit 43e3a40

File tree

10,235 files changed

+24929
-24707
lines changed

Some content is hidden

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

10,235 files changed

+24929
-24707
lines changed

.circleci/config.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
- checkout
8888
- run:
8989
name: Install black
90-
command: "sudo pip install black==19.10b0"
90+
command: "sudo pip install black==22.3.0"
9191
- run:
9292
name: Check formatting with black
9393
command: "black --check ."
@@ -385,7 +385,6 @@ jobs:
385385
destination: doc/apidoc/_build/
386386

387387
workflows:
388-
389388
code_formatting:
390389
jobs:
391390
- check-code-formatting

.pre-commit-config.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
2-
- repo: https://github.com/ambv/black
3-
rev: 19.10b0
2+
- repo: https://github.com/ambv/black
3+
rev: 22.3.0
44
hooks:
5-
- id: black
6-
language_version: python
5+
- id: black
6+
language_version: python

packages/python/chart-studio/chart_studio/grid_objs/grid_objs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def _to_plotly_grid_json(self):
269269
return grid_json
270270

271271
def get_column(self, column_name):
272-
""" Return the first column with name `column_name`.
272+
"""Return the first column with name `column_name`.
273273
If no column with `column_name` exists in this grid, return None.
274274
"""
275275
for column in self._columns:

packages/python/chart-studio/chart_studio/plotly/chunked_requests/chunked_request.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def __init__(
1919
ssl_enabled=False,
2020
ssl_verification_enabled=True,
2121
):
22-
""" Initialize a stream object and an HTTP or HTTPS connection
22+
"""Initialize a stream object and an HTTP or HTTPS connection
2323
with chunked Transfer-Encoding to server:port with optional headers.
2424
"""
2525
self.maxtries = 5
@@ -35,7 +35,7 @@ def __init__(
3535
self._connect()
3636

3737
def write(self, data, reconnect_on=("", 200, 502)):
38-
""" Send `data` to the server in chunk-encoded form.
38+
"""Send `data` to the server in chunk-encoded form.
3939
Check the connection before writing and reconnect
4040
if disconnected and if the response status code is in `reconnect_on`.
4141
@@ -140,7 +140,7 @@ def _get_ssl_context(self):
140140
return context
141141

142142
def _connect(self):
143-
""" Initialize an HTTP/HTTPS connection with chunked Transfer-Encoding
143+
"""Initialize an HTTP/HTTPS connection with chunked Transfer-Encoding
144144
to server:port with optional headers.
145145
"""
146146
server = self._server
@@ -184,7 +184,7 @@ def _connect(self):
184184
time.sleep(0.5)
185185

186186
def close(self):
187-
""" Close the connection to server.
187+
"""Close the connection to server.
188188
189189
If available, return a http_client.HTTPResponse object.
190190
@@ -206,7 +206,7 @@ def close(self):
206206
return self._getresponse()
207207

208208
def _getresponse(self):
209-
""" Read from recv and return a HTTPResponse object if possible.
209+
"""Read from recv and return a HTTPResponse object if possible.
210210
Either
211211
1 - The client has succesfully closed the connection: Return ''
212212
2 - The server has already closed the connection: Return the response
@@ -244,7 +244,7 @@ def _getresponse(self):
244244
return response
245245

246246
def _isconnected(self):
247-
""" Return True if the socket is still connected
247+
"""Return True if the socket is still connected
248248
to the server, False otherwise.
249249
250250
This check is done in 3 steps:
@@ -314,7 +314,7 @@ def _isconnected(self):
314314
raise e
315315

316316
def _reconnect(self):
317-
""" Connect if disconnected.
317+
"""Connect if disconnected.
318318
Retry self.maxtries times with delays
319319
"""
320320
if not self._isconnected():
@@ -340,8 +340,7 @@ def _reconnect(self):
340340
self._closed = False
341341

342342
def _reset_retries(self):
343-
""" Reset the connect counters and delays
344-
"""
343+
"""Reset the connect counters and delays"""
345344
self._tries = 0
346345
self._delay = 1
347346

packages/python/chart-studio/chart_studio/session.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def update_session_plot_options(**kwargs):
142142

143143

144144
def get_session_plot_options():
145-
""" Returns a copy of the user supplied plot options.
145+
"""Returns a copy of the user supplied plot options.
146146
Use `update_plot_options()` to change.
147147
"""
148148
return copy.deepcopy(_session["plot_options"])

packages/python/chart-studio/chart_studio/tests/test_plot_ly/test_image/test_image.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ def test_image_save_as_saves_valid_image(
5454
data = setup_image
5555
f, filename = tempfile.mkstemp(".{}".format(image_format))
5656
py.image.save_as(
57-
data, filename, format=image_format, width=width, height=height, scale=scale,
57+
data,
58+
filename,
59+
format=image_format,
60+
width=width,
61+
height=height,
62+
scale=scale,
5863
)
5964
if image_format in ["png", "jpeg"]:
6065
assert imghdr.what(filename) == image_format

packages/python/chart-studio/chart_studio/tests/test_plot_ly/test_plotly/test_plot.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def test(self):
319319

320320

321321
def generate_conflicting_plot_options_with_json_writes_of_config():
322-
""" if the user wrote their own options in the config file,
322+
"""if the user wrote their own options in the config file,
323323
then we'll raise the error when the call plot or iplot through
324324
_plot_option_logic
325325
"""
@@ -346,7 +346,7 @@ def test(self):
346346

347347

348348
def generate_private_sharing_and_public_world_readable_precedence():
349-
""" Test that call signature arguments applied through _plot_option_logic
349+
"""Test that call signature arguments applied through _plot_option_logic
350350
overwrite options supplied through py.sign_in which overwrite options
351351
set through tls.set_config
352352
"""

packages/python/chart-studio/chart_studio/tests/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def setUp(self):
2525
self.stash_files()
2626
defaults = dict(
2727
files.FILE_CONTENT[files.CREDENTIALS_FILE],
28-
**files.FILE_CONTENT[files.CONFIG_FILE]
28+
**files.FILE_CONTENT[files.CONFIG_FILE],
2929
)
3030
session.sign_in(**defaults)
3131

packages/python/plotly/_plotly_utils/basevalidators.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ def __init__(
429429
values,
430430
array_ok=False,
431431
coerce_number=False,
432-
**kwargs
432+
**kwargs,
433433
):
434434
super(EnumeratedValidator, self).__init__(
435435
plotly_name=plotly_name, parent_name=parent_name, **kwargs
@@ -967,7 +967,7 @@ def __init__(
967967
strict=False,
968968
array_ok=False,
969969
values=None,
970-
**kwargs
970+
**kwargs,
971971
):
972972
super(StringValidator, self).__init__(
973973
plotly_name=plotly_name, parent_name=parent_name, **kwargs
@@ -1406,7 +1406,7 @@ def find_invalid_els(self, orig, validated, invalid_els=None):
14061406
return invalid_els
14071407

14081408
def vc_scalar(self, v):
1409-
""" Helper to validate/coerce a scalar color """
1409+
"""Helper to validate/coerce a scalar color"""
14101410
return ColorValidator.perform_validate_coerce(
14111411
v, allow_number=self.numbers_allowed()
14121412
)
@@ -1956,7 +1956,7 @@ def __init__(
19561956
items,
19571957
free_length=None,
19581958
dimensions=None,
1959-
**kwargs
1959+
**kwargs,
19601960
):
19611961
super(InfoArrayValidator, self).__init__(
19621962
plotly_name=plotly_name, parent_name=parent_name, **kwargs
@@ -2711,7 +2711,7 @@ def __init__(self, plotly_name, parent_name, data_class_str, data_docs, **kwargs
27112711
parent_name=parent_name,
27122712
data_class_str=data_class_str,
27132713
data_docs=data_docs,
2714-
**kwargs
2714+
**kwargs,
27152715
)
27162716

27172717
def description(self):

packages/python/plotly/_plotly_utils/png.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def __init__(
375375
planes=None,
376376
colormap=None,
377377
maxval=None,
378-
chunk_limit=2 ** 20,
378+
chunk_limit=2**20,
379379
x_pixels_per_unit=None,
380380
y_pixels_per_unit=None,
381381
unit_is_meter=False,
@@ -544,7 +544,7 @@ def __init__(
544544
if width <= 0 or height <= 0:
545545
raise ProtocolError("width and height must be greater than zero")
546546
# http://www.w3.org/TR/PNG/#7Integers-and-byte-order
547-
if width > 2 ** 31 - 1 or height > 2 ** 31 - 1:
547+
if width > 2**31 - 1 or height > 2**31 - 1:
548548
raise ProtocolError("width and height cannot exceed 2**31-1")
549549

550550
if alpha and transparent is not None:
@@ -918,7 +918,7 @@ def write_chunk(outfile, tag, data=b""):
918918
outfile.write(data)
919919
checksum = zlib.crc32(tag)
920920
checksum = zlib.crc32(data, checksum)
921-
checksum &= 2 ** 32 - 1
921+
checksum &= 2**32 - 1
922922
outfile.write(struct.pack("!I", checksum))
923923

924924

@@ -1548,7 +1548,7 @@ def _bytes_to_values(self, bs, width=None):
15481548
# Samples per byte
15491549
spb = 8 // self.bitdepth
15501550
out = bytearray()
1551-
mask = 2 ** self.bitdepth - 1
1551+
mask = 2**self.bitdepth - 1
15521552
shifts = [self.bitdepth * i for i in reversed(list(range(spb)))]
15531553
for o in bs:
15541554
out.extend([mask & (o >> i) for i in shifts])
@@ -1632,7 +1632,7 @@ def _chunk_len_type(self):
16321632
if len(x) != 8:
16331633
raise FormatError("End of file whilst reading chunk length and type.")
16341634
length, type = struct.unpack("!I4s", x)
1635-
if length > 2 ** 31 - 1:
1635+
if length > 2**31 - 1:
16361636
raise FormatError("Chunk %s is too large: %d." % (type, length))
16371637
# Check that all bytes are in valid ASCII range.
16381638
# https://www.w3.org/TR/2003/REC-PNG-20031110/#5Chunk-layout
@@ -1722,7 +1722,7 @@ def _process_PLTE(self, data):
17221722
self.plte = data
17231723
if len(data) % 3 != 0:
17241724
raise FormatError("PLTE chunk's length should be a multiple of 3.")
1725-
if len(data) > (2 ** self.bitdepth) * 3:
1725+
if len(data) > (2**self.bitdepth) * 3:
17261726
raise FormatError("PLTE chunk is too long.")
17271727
if len(data) == 0:
17281728
raise FormatError("Empty PLTE is not allowed.")
@@ -2014,7 +2014,7 @@ def _as_rescale(self, get, targetbitdepth):
20142014

20152015
width, height, pixels, info = get()
20162016
maxval = 2 ** info["bitdepth"] - 1
2017-
targetmaxval = 2 ** targetbitdepth - 1
2017+
targetmaxval = 2**targetbitdepth - 1
20182018
factor = float(targetmaxval) / float(maxval)
20192019
info["bitdepth"] = targetbitdepth
20202020

packages/python/plotly/codegen/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,9 @@ def __getattr__(import_name):
337337
f.write(graph_objects_init_source)
338338

339339
# ### Run black code formatter on output directories ###
340-
subprocess.call(["black", "--target-version=py27", validators_pkgdir])
341-
subprocess.call(["black", "--target-version=py27", graph_objs_pkgdir])
342-
subprocess.call(["black", "--target-version=py27", graph_objects_path])
340+
subprocess.call(["black", "--target-version=py36", validators_pkgdir])
341+
subprocess.call(["black", "--target-version=py36", graph_objs_pkgdir])
342+
subprocess.call(["black", "--target-version=py36", graph_objects_path])
343343

344344

345345
if __name__ == "__main__":

packages/python/plotly/optional-requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ psutil
2525

2626
## code formatting
2727
pre-commit
28-
black==19.10b0
28+
black==22.3.0
2929

3030

3131
## codegen dependencies ##

0 commit comments

Comments
 (0)