mirror of
https://github.com/pyecharts/pyecharts.git
synced 2026-01-25 17:06:27 +00:00
PR: Typehint (#1037)
* Update: Typehint 尽量使用 Sequence 代替 List,Sequence 包含了 List, Tuple, Set * Format: code
This commit is contained in:
parent
1b783ca3fa
commit
61ffd70dcd
@ -40,7 +40,7 @@ def bar_toolbox() -> Bar:
|
||||
.set_global_opts(
|
||||
title_opts=opts.TitleOpts(title="Bar-显示 ToolBox"),
|
||||
toolbox_opts=opts.ToolboxOpts(),
|
||||
legend_opts=opts.LegendOpts(is_show=False)
|
||||
legend_opts=opts.LegendOpts(is_show=False),
|
||||
)
|
||||
)
|
||||
return c
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
# coding=utf-8
|
||||
from ... import options as opts
|
||||
from ...charts.chart import Chart
|
||||
from ...commons.types import List, Numeric, Optional, Union
|
||||
from ...commons.types import Numeric, Optional, Sequence, Union
|
||||
from ...globals import ChartType
|
||||
|
||||
|
||||
@ -18,9 +18,9 @@ class Graph(Chart):
|
||||
def add(
|
||||
self,
|
||||
series_name: str,
|
||||
nodes: List[Union[opts.GraphNode, dict]],
|
||||
links: List[Union[opts.GraphLink, dict]],
|
||||
categories: Union[List[Union[opts.GraphCategory, dict]], None] = None,
|
||||
nodes: Sequence[Union[opts.GraphNode, dict]],
|
||||
links: Sequence[Union[opts.GraphLink, dict]],
|
||||
categories: Union[Sequence[Union[opts.GraphCategory, dict]], None] = None,
|
||||
*,
|
||||
is_selected: bool = True,
|
||||
is_focusnode: bool = True,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
# coding=utf-8
|
||||
from ... import options as opts
|
||||
from ...charts.chart import Chart
|
||||
from ...commons.types import List, Optional, Sequence, Union
|
||||
from ...commons.types import Optional, Sequence, Union
|
||||
from ...globals import ChartType
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ class Liquid(Chart):
|
||||
data: Sequence,
|
||||
*,
|
||||
shape: str = "circle",
|
||||
color: Optional[List[str]] = None,
|
||||
color: Optional[Sequence[str]] = None,
|
||||
is_animation: bool = True,
|
||||
is_outline_show: bool = True,
|
||||
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
# coding=utf-8
|
||||
from ... import options as opts
|
||||
from ...charts.chart import Chart
|
||||
from ...commons.types import Optional, Sequence, Union, List, Numeric
|
||||
from ...commons.types import Numeric, Optional, Sequence, Union
|
||||
from ...globals import ChartType
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ class Map(Chart):
|
||||
*,
|
||||
is_selected: bool = True,
|
||||
is_roam: bool = True,
|
||||
center: Optional[List] = None,
|
||||
center: Optional[Sequence] = None,
|
||||
zoom: Optional[Numeric] = 1,
|
||||
name_map: Optional[dict] = None,
|
||||
symbol: Optional[str] = None,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
# coding=utf-8
|
||||
from ... import options as opts
|
||||
from ...charts.chart import Chart
|
||||
from ...commons.types import List, Sequence, Union
|
||||
from ...commons.types import Sequence, Union
|
||||
from ...globals import ChartType
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ class Parallel(Chart):
|
||||
|
||||
def add_schema(
|
||||
self,
|
||||
schema: List[Union[opts.ParallelAxisOpts, dict]],
|
||||
schema: Sequence[Union[opts.ParallelAxisOpts, dict]],
|
||||
parallel_opts: Union[opts.ParallelOpts, dict, None] = None,
|
||||
):
|
||||
sc = []
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
# coding=utf-8
|
||||
from ... import options as opts
|
||||
from ...charts.chart import Chart
|
||||
from ...commons.types import List, Optional, Sequence, Union
|
||||
from ...commons.types import Optional, Sequence, Union
|
||||
from ...globals import ChartType
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ class Radar(Chart):
|
||||
|
||||
def add_schema(
|
||||
self,
|
||||
schema: List[Union[opts.RadarIndicatorItem, dict]],
|
||||
schema: Sequence[Union[opts.RadarIndicatorItem, dict]],
|
||||
shape: Optional[str] = None,
|
||||
textstyle_opts: Union[opts.TextStyleOpts, dict] = opts.TextStyleOpts(),
|
||||
splitline_opt: Union[opts.SplitLineOpts, dict] = opts.SplitLineOpts(
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
# coding=utf-8
|
||||
from ... import options as opts
|
||||
from ...charts.chart import Chart
|
||||
from ...commons.types import List, Numeric, Optional, Union
|
||||
from ...commons.types import Numeric, Optional, Sequence, Union
|
||||
from ...globals import ChartType
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ class Tree(Chart):
|
||||
def add(
|
||||
self,
|
||||
series_name: str,
|
||||
data: List[Union[opts.TreeItem, dict]],
|
||||
data: Sequence[Union[opts.TreeItem, dict]],
|
||||
*,
|
||||
layout: str = "orthogonal",
|
||||
symbol: str = "emptyCircle",
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
# coding=utf-8
|
||||
from ... import options as opts
|
||||
from ...charts.chart import Chart
|
||||
from ...commons.types import List, Numeric, Optional, Union
|
||||
from ...commons.types import Numeric, Optional, Sequence, Union
|
||||
from ...globals import ChartType
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ class TreeMap(Chart):
|
||||
def add(
|
||||
self,
|
||||
series_name: str,
|
||||
data: List[Union[opts.TreeItem, dict]],
|
||||
data: Sequence[Union[opts.TreeItem, dict]],
|
||||
*,
|
||||
is_selected: bool = True,
|
||||
leaf_depth: Optional[Numeric] = None,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
# coding=utf-8
|
||||
from .. import options as opts
|
||||
from ..charts.base import Base
|
||||
from ..commons.types import List, Numeric, Optional, Sequence, Union
|
||||
from ..commons.types import Optional, Sequence, Union
|
||||
from ..globals import RenderType, ThemeType
|
||||
|
||||
|
||||
@ -127,9 +127,9 @@ class Chart(Base):
|
||||
xaxis_opts: Union[opts.AxisOpts, dict, None] = None,
|
||||
yaxis_opts: Union[opts.AxisOpts, dict, None] = None,
|
||||
visualmap_opts: Union[
|
||||
opts.VisualMapOpts, List[Union[opts.VisualMapOpts, dict]], dict, None
|
||||
opts.VisualMapOpts, Sequence[Union[opts.VisualMapOpts, dict]], dict, None
|
||||
] = None,
|
||||
datazoom_opts: List[Union[opts.DataZoomOpts, dict, None]] = None,
|
||||
datazoom_opts: Sequence[Union[opts.DataZoomOpts, dict, None]] = None,
|
||||
):
|
||||
if isinstance(title_opts, opts.TitleOpts):
|
||||
title_opts = title_opts.opts
|
||||
|
||||
@ -4,7 +4,7 @@ import os
|
||||
from jinja2 import Environment
|
||||
from prettytable import PrettyTable
|
||||
|
||||
from ..commons.types import List, Optional
|
||||
from ..commons.types import Optional, Sequence
|
||||
from ..globals import CurrentConfig
|
||||
from ..render.display import HTML
|
||||
from ..render.engine import RenderEngine
|
||||
@ -20,7 +20,7 @@ class Table:
|
||||
self.js_host = js_host
|
||||
self._charts = []
|
||||
|
||||
def add(self, headers: List, rows: List):
|
||||
def add(self, headers: Sequence, rows: Sequence):
|
||||
table = PrettyTable(headers)
|
||||
for r in rows:
|
||||
table.add_row(r)
|
||||
|
||||
@ -139,8 +139,8 @@ class DataZoomOpts:
|
||||
start_value: Union[int, str, None] = None,
|
||||
end_value: Union[int, str, None] = None,
|
||||
orient: str = "horizontal",
|
||||
xaxis_index: Union[int, List[int], None] = None,
|
||||
yaxis_index: Union[int, List[int], None] = None,
|
||||
xaxis_index: Union[int, Sequence[int], None] = None,
|
||||
yaxis_index: Union[int, Sequence[int], None] = None,
|
||||
is_zoom_lock: bool = False,
|
||||
):
|
||||
self.opts: dict = {
|
||||
@ -193,9 +193,9 @@ class VisualMapOpts:
|
||||
type_: str = "color",
|
||||
min_: Numeric = 0,
|
||||
max_: Numeric = 100,
|
||||
range_text: Union[list, tuple] = None,
|
||||
range_color: Union[List[str]] = None,
|
||||
range_size: Union[List[int]] = None,
|
||||
range_text: Optional[Sequence] = None,
|
||||
range_color: Optional[Sequence[str]] = None,
|
||||
range_size: Optional[Sequence[int]] = None,
|
||||
orient: str = "vertical",
|
||||
pos_left: Optional[str] = None,
|
||||
pos_right: Optional[str] = None,
|
||||
@ -615,8 +615,8 @@ class RadiusAxisOpts:
|
||||
def __init__(
|
||||
self,
|
||||
polar_index: Optional[int] = None,
|
||||
data: Optional[List[Union[RadiusAxisItem, dict, str]]] = None,
|
||||
boundary_gap: Union[bool, List] = None,
|
||||
data: Optional[Sequence[Union[RadiusAxisItem, dict, str]]] = None,
|
||||
boundary_gap: Union[bool, Sequence] = None,
|
||||
type_: Optional[str] = None,
|
||||
name: Optional[str] = None,
|
||||
name_location: Optional[str] = None,
|
||||
@ -663,10 +663,10 @@ class AngleAxisOpts:
|
||||
def __init__(
|
||||
self,
|
||||
polar_index: Optional[int] = None,
|
||||
data: Optional[List[Union[AngleAxisItem, Numeric, dict, str]]] = None,
|
||||
data: Optional[Sequence[Union[AngleAxisItem, Numeric, dict, str]]] = None,
|
||||
start_angle: Optional[Numeric] = None,
|
||||
is_clockwise: bool = False,
|
||||
boundary_gap: Union[bool, List] = None,
|
||||
boundary_gap: Union[bool, Sequence, None] = None,
|
||||
type_: Optional[str] = None,
|
||||
min_: Union[str, Numeric, None] = None,
|
||||
max_: Union[str, Numeric, None] = None,
|
||||
|
||||
@ -36,8 +36,8 @@ class TextStyleOpts:
|
||||
background_color: Optional[str] = None,
|
||||
border_color: Optional[str] = None,
|
||||
border_width: Optional[Numeric] = None,
|
||||
border_radius: Union[Numeric, List, None] = None,
|
||||
padding: Union[Numeric, List, None] = None,
|
||||
border_radius: Union[Numeric, Sequence, None] = None,
|
||||
padding: Union[Numeric, Sequence, None] = None,
|
||||
shadow_color: Optional[str] = None,
|
||||
shadow_blur: Optional[Numeric] = None,
|
||||
width: Optional[str] = None,
|
||||
@ -107,7 +107,7 @@ class LineStyleOpts:
|
||||
opacity: Numeric = 1,
|
||||
curve: Numeric = 0,
|
||||
type_: str = "solid",
|
||||
color: Union[str, List, None] = None,
|
||||
color: Union[str, Sequence, None] = None,
|
||||
):
|
||||
self.opts: dict = {
|
||||
"width": width,
|
||||
@ -135,12 +135,12 @@ class MarkPointItem:
|
||||
type_: Optional[str] = None,
|
||||
value_index: Optional[Numeric] = None,
|
||||
value_dim: Optional[str] = None,
|
||||
coord: Optional[List] = None,
|
||||
coord: Optional[Sequence] = None,
|
||||
x: Optional[Numeric] = None,
|
||||
y: Optional[Numeric] = None,
|
||||
value: Optional[Numeric] = None,
|
||||
symbol: Optional[str] = None,
|
||||
symbol_size: Union[Numeric, List] = None,
|
||||
symbol_size: Union[Numeric, Sequence, None] = None,
|
||||
):
|
||||
self.opts: dict = {
|
||||
"name": name,
|
||||
@ -159,7 +159,7 @@ class MarkPointItem:
|
||||
class MarkPointOpts:
|
||||
def __init__(
|
||||
self,
|
||||
data: List[Union[MarkPointItem, dict]] = None,
|
||||
data: Sequence[Union[MarkPointItem, dict]] = None,
|
||||
symbol: Optional[str] = None,
|
||||
symbol_size: Union[None, Numeric] = None,
|
||||
label_opts: LabelOpts = LabelOpts(position="inside", color="#fff"),
|
||||
@ -212,7 +212,7 @@ class MarkLineOpts:
|
||||
def __init__(
|
||||
self,
|
||||
is_silent: bool = False,
|
||||
data: List[Union[MarkLineItem, dict]] = None,
|
||||
data: Sequence[Union[MarkLineItem, dict]] = None,
|
||||
symbol: Optional[str] = None,
|
||||
symbol_size: Union[None, Numeric] = None,
|
||||
precision: int = 2,
|
||||
@ -280,7 +280,7 @@ class MarkAreaOpts:
|
||||
self,
|
||||
is_silent: bool = False,
|
||||
label_opts: LabelOpts = LabelOpts(),
|
||||
data: List[Union[MarkAreaItem, dict]] = None,
|
||||
data: Sequence[Union[MarkAreaItem, dict]] = None,
|
||||
):
|
||||
if isinstance(label_opts, LabelOpts):
|
||||
label_opts = label_opts.opts
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user