Skip to content

Commit 693cd5e

Browse files
committed
feat: adding type annotations to some constructor parameters
Using `get_typing_type` from `codegen/datatypes.py` to add Python datatype to some constructor parameters. Notes: 1. Does not handle the `compound` datatype yet. `get_typing_type` raises a `ValueError` because it doesn't have a clause for this type; `add_constructor_params` catches this and simply doesn't add a type definition. Something between a third and half of all constructor parameters suffer from this, so we need to figure out what `compound` means and define a type for it. 2. Almost all parameters are nullable, so the type is defined as (for example) `int` but the default value assigned is `None`.
1 parent dbbbaa8 commit 693cd5e

File tree

1,010 files changed

+15648
-15644
lines changed

Some content is hidden

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

1,010 files changed

+15648
-15644
lines changed

packages/python/plotly/codegen/datatypes.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -474,10 +474,14 @@ def add_constructor_params(
474474
{extra}=None"""
475475
)
476476

477-
for i, subtype_node in enumerate(subtype_nodes):
477+
for subtype_node in subtype_nodes:
478+
try:
479+
py_type = f": {get_typing_type(subtype_node.datatype)}"
480+
except ValueError: # FIXME
481+
py_type = ""
478482
buffer.write(
479483
f""",
480-
{subtype_node.name_property}=None"""
484+
{subtype_node.name_property}{py_type}=None"""
481485
)
482486

483487
for extra in append_extras:

packages/python/plotly/plotly/graph_objs/_bar.py

+63-63
Original file line numberDiff line numberDiff line change
@@ -2107,80 +2107,80 @@ def _prop_descriptions(self):
21072107
"""
21082108
def __init__(self,
21092109
arg=None,
2110-
alignmentgroup=None,
2111-
base=None,
2112-
basesrc=None,
2113-
cliponaxis=None,
2114-
constraintext=None,
2115-
customdata=None,
2116-
customdatasrc=None,
2117-
dx=None,
2118-
dy=None,
2110+
alignmentgroup: str=None,
2111+
base: Any=None,
2112+
basesrc: str=None,
2113+
cliponaxis: bool=None,
2114+
constraintext: Any=None,
2115+
customdata: numpy.ndarray=None,
2116+
customdatasrc: str=None,
2117+
dx: int|float=None,
2118+
dy: int|float=None,
21192119
error_x=None,
21202120
error_y=None,
2121-
hoverinfo=None,
2122-
hoverinfosrc=None,
2121+
hoverinfo: Any=None,
2122+
hoverinfosrc: str=None,
21232123
hoverlabel=None,
2124-
hovertemplate=None,
2125-
hovertemplatesrc=None,
2126-
hovertext=None,
2127-
hovertextsrc=None,
2128-
ids=None,
2129-
idssrc=None,
2130-
insidetextanchor=None,
2124+
hovertemplate: str=None,
2125+
hovertemplatesrc: str=None,
2126+
hovertext: str=None,
2127+
hovertextsrc: str=None,
2128+
ids: numpy.ndarray=None,
2129+
idssrc: str=None,
2130+
insidetextanchor: Any=None,
21312131
insidetextfont=None,
2132-
legend=None,
2133-
legendgroup=None,
2132+
legend: str=None,
2133+
legendgroup: str=None,
21342134
legendgrouptitle=None,
2135-
legendrank=None,
2136-
legendwidth=None,
2135+
legendrank: int|float=None,
2136+
legendwidth: int|float=None,
21372137
marker=None,
2138-
meta=None,
2139-
metasrc=None,
2140-
name=None,
2141-
offset=None,
2142-
offsetgroup=None,
2143-
offsetsrc=None,
2144-
opacity=None,
2145-
orientation=None,
2138+
meta: Any=None,
2139+
metasrc: str=None,
2140+
name: str=None,
2141+
offset: int|float=None,
2142+
offsetgroup: str=None,
2143+
offsetsrc: str=None,
2144+
opacity: int|float=None,
2145+
orientation: Any=None,
21462146
outsidetextfont=None,
21472147
selected=None,
2148-
selectedpoints=None,
2149-
showlegend=None,
2148+
selectedpoints: Any=None,
2149+
showlegend: bool=None,
21502150
stream=None,
2151-
text=None,
2152-
textangle=None,
2151+
text: str=None,
2152+
textangle: int|float=None,
21532153
textfont=None,
2154-
textposition=None,
2155-
textpositionsrc=None,
2156-
textsrc=None,
2157-
texttemplate=None,
2158-
texttemplatesrc=None,
2159-
uid=None,
2160-
uirevision=None,
2154+
textposition: Any=None,
2155+
textpositionsrc: str=None,
2156+
textsrc: str=None,
2157+
texttemplate: str=None,
2158+
texttemplatesrc: str=None,
2159+
uid: str=None,
2160+
uirevision: Any=None,
21612161
unselected=None,
2162-
visible=None,
2163-
width=None,
2164-
widthsrc=None,
2165-
x=None,
2166-
x0=None,
2167-
xaxis=None,
2168-
xcalendar=None,
2169-
xhoverformat=None,
2170-
xperiod=None,
2171-
xperiod0=None,
2172-
xperiodalignment=None,
2173-
xsrc=None,
2174-
y=None,
2175-
y0=None,
2176-
yaxis=None,
2177-
ycalendar=None,
2178-
yhoverformat=None,
2179-
yperiod=None,
2180-
yperiod0=None,
2181-
yperiodalignment=None,
2182-
ysrc=None,
2183-
zorder=None,
2162+
visible: Any=None,
2163+
width: int|float=None,
2164+
widthsrc: str=None,
2165+
x: numpy.ndarray=None,
2166+
x0: Any=None,
2167+
xaxis: str=None,
2168+
xcalendar: Any=None,
2169+
xhoverformat: str=None,
2170+
xperiod: Any=None,
2171+
xperiod0: Any=None,
2172+
xperiodalignment: Any=None,
2173+
xsrc: str=None,
2174+
y: numpy.ndarray=None,
2175+
y0: Any=None,
2176+
yaxis: str=None,
2177+
ycalendar: Any=None,
2178+
yhoverformat: str=None,
2179+
yperiod: Any=None,
2180+
yperiod0: Any=None,
2181+
yperiodalignment: Any=None,
2182+
ysrc: str=None,
2183+
zorder: int=None,
21842184
**kwargs
21852185
):
21862186
"""

packages/python/plotly/plotly/graph_objs/_barpolar.py

+41-41
Original file line numberDiff line numberDiff line change
@@ -1299,53 +1299,53 @@ def _prop_descriptions(self):
12991299
"""
13001300
def __init__(self,
13011301
arg=None,
1302-
base=None,
1303-
basesrc=None,
1304-
customdata=None,
1305-
customdatasrc=None,
1306-
dr=None,
1307-
dtheta=None,
1308-
hoverinfo=None,
1309-
hoverinfosrc=None,
1302+
base: Any=None,
1303+
basesrc: str=None,
1304+
customdata: numpy.ndarray=None,
1305+
customdatasrc: str=None,
1306+
dr: int|float=None,
1307+
dtheta: int|float=None,
1308+
hoverinfo: Any=None,
1309+
hoverinfosrc: str=None,
13101310
hoverlabel=None,
1311-
hovertemplate=None,
1312-
hovertemplatesrc=None,
1313-
hovertext=None,
1314-
hovertextsrc=None,
1315-
ids=None,
1316-
idssrc=None,
1317-
legend=None,
1318-
legendgroup=None,
1311+
hovertemplate: str=None,
1312+
hovertemplatesrc: str=None,
1313+
hovertext: str=None,
1314+
hovertextsrc: str=None,
1315+
ids: numpy.ndarray=None,
1316+
idssrc: str=None,
1317+
legend: str=None,
1318+
legendgroup: str=None,
13191319
legendgrouptitle=None,
1320-
legendrank=None,
1321-
legendwidth=None,
1320+
legendrank: int|float=None,
1321+
legendwidth: int|float=None,
13221322
marker=None,
1323-
meta=None,
1324-
metasrc=None,
1325-
name=None,
1326-
offset=None,
1327-
offsetsrc=None,
1328-
opacity=None,
1329-
r=None,
1330-
r0=None,
1331-
rsrc=None,
1323+
meta: Any=None,
1324+
metasrc: str=None,
1325+
name: str=None,
1326+
offset: int|float=None,
1327+
offsetsrc: str=None,
1328+
opacity: int|float=None,
1329+
r: numpy.ndarray=None,
1330+
r0: Any=None,
1331+
rsrc: str=None,
13321332
selected=None,
1333-
selectedpoints=None,
1334-
showlegend=None,
1333+
selectedpoints: Any=None,
1334+
showlegend: bool=None,
13351335
stream=None,
1336-
subplot=None,
1337-
text=None,
1338-
textsrc=None,
1339-
theta=None,
1340-
theta0=None,
1341-
thetasrc=None,
1342-
thetaunit=None,
1343-
uid=None,
1344-
uirevision=None,
1336+
subplot: str=None,
1337+
text: str=None,
1338+
textsrc: str=None,
1339+
theta: numpy.ndarray=None,
1340+
theta0: Any=None,
1341+
thetasrc: str=None,
1342+
thetaunit: Any=None,
1343+
uid: str=None,
1344+
uirevision: Any=None,
13451345
unselected=None,
1346-
visible=None,
1347-
width=None,
1348-
widthsrc=None,
1346+
visible: Any=None,
1347+
width: int|float=None,
1348+
widthsrc: str=None,
13491349
**kwargs
13501350
):
13511351
"""

0 commit comments

Comments
 (0)