Skip to content

Commit c3dbd41

Browse files
committed
feat: update black and format code to match Python 3.11
1. Update required version of `black` in `pyproject.toml` and `.circleci/config.yml`. 2. Update Python version identifiers in `tool.black` section of `pyproject.toml` to include `py311` and `py312`. 3. Modify invocation of `black` in `commands.py` to format with `py311`. 4. Regenerate and reformat code.
1 parent 51911a4 commit c3dbd41

37 files changed

+69
-26
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ jobs:
129129
command: |
130130
python -m venv venv
131131
. venv/bin/activate
132-
pip install black==22.3.0
132+
pip install black==25.1.0
133133
- run:
134134
name: Check formatting with black
135135
command: |

_plotly_utils/colors/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
Be careful! If you have a lot of unique numbers in your color column you will
7474
end up with a colormap that is massive and may slow down graphing performance.
7575
"""
76+
7677
import decimal
7778
from numbers import Number
7879

codegen/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
get_data_validator_instance,
2727
)
2828

29+
# Target Python version for code formatting with Black.
30+
# Must be one of the values listed in pyproject.toml.
31+
BLACK_TARGET_VERSION = "py311"
32+
2933

3034
# Import notes
3135
# ------------
@@ -326,9 +330,10 @@ def __getattr__(import_name):
326330

327331
# ### Run black code formatter on output directories ###
328332
if reformat:
329-
subprocess.call(["black", "--target-version=py36", validators_pkgdir])
330-
subprocess.call(["black", "--target-version=py36", graph_objs_pkgdir])
331-
subprocess.call(["black", "--target-version=py36", graph_objects_path])
333+
target_version = f"--target-version={BLACK_TARGET_VERSION}"
334+
subprocess.call(["black", target_version, validators_pkgdir])
335+
subprocess.call(["black", target_version, graph_objs_pkgdir])
336+
subprocess.call(["black", target_version, graph_objects_path])
332337
else:
333338
print("skipping reformatting")
334339

commands.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
]
2323
)
2424

25+
2526
# Load plotly.js version from js/package.json
2627
def plotly_js_version():
2728
path = os.path.join(PROJECT_ROOT, "js", "package.json")

plotly/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
- exceptions: defines our custom exception classes
2626
2727
"""
28+
2829
import sys
2930
from typing import TYPE_CHECKING
3031
from _plotly_utils.importers import relative_import

plotly/basedatatypes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def _make_underscore_key(key):
8686
return key.replace("-", "_")
8787

8888
key_path2b = list(map(_make_hyphen_key, key_path2))
89+
8990
# Here we want to split up each non-empty string in the list at
9091
# underscores and recombine the strings using chomp_empty_strings so
9192
# that leading, trailing and multiple _ will be preserved
@@ -1611,6 +1612,7 @@ def _add_annotation_like(
16111612
)
16121613
):
16131614
return self
1615+
16141616
# in case the user specified they wanted an axis to refer to the
16151617
# domain of that axis and not the data, append ' domain' to the
16161618
# computed axis accordingly

plotly/data/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Built-in datasets for demonstration, educational and test purposes.
33
"""
4+
45
import os
56
from importlib import import_module
67

plotly/express/_core.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -985,9 +985,11 @@ def make_trace_spec(args, constructor, attrs, trace_patch):
985985

986986
def make_trendline_spec(args, constructor):
987987
trace_spec = TraceSpec(
988-
constructor=go.Scattergl
989-
if constructor == go.Scattergl # could be contour
990-
else go.Scatter,
988+
constructor=(
989+
go.Scattergl
990+
if constructor == go.Scattergl # could be contour
991+
else go.Scatter
992+
),
991993
attrs=["trendline"],
992994
trace_patch=dict(mode="lines"),
993995
marginal=None,
@@ -2456,9 +2458,11 @@ def get_groups_and_orders(args, grouper):
24562458
full_sorted_group_names = [
24572459
tuple(
24582460
[
2459-
""
2460-
if col == one_group
2461-
else sub_group_names[required_grouper.index(col)]
2461+
(
2462+
""
2463+
if col == one_group
2464+
else sub_group_names[required_grouper.index(col)]
2465+
)
24622466
for col in grouper
24632467
]
24642468
)

plotly/express/data/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""Built-in datasets for demonstration, educational and test purposes.
2-
"""
1+
"""Built-in datasets for demonstration, educational and test purposes."""
32

43
from plotly.data import *
54

plotly/io/_templates.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ def _merge_2_templates(self, template1, template2):
273273
templates = TemplatesConfig()
274274
del TemplatesConfig
275275

276+
276277
# Template utilities
277278
# ------------------
278279
def walk_push_to_template(fig_obj, template_obj, skip):

0 commit comments

Comments
 (0)