Skip to content

Commit

Permalink
Lias (pyecharts#722)
Browse files Browse the repository at this point in the history
* Add: 新增 lias 工具格式化 imports

* Update: 细节修正

* Fix: fix pyecharts#721

* Update: var reused

* Format: 格式化导包顺序

* Update: modules import order: python builtin imports on top, 3rd parties libraries in the middle, package's own libraries in the bottom
  • Loading branch information
chenjiandongx authored Sep 1, 2018
1 parent 7666d1c commit d2c4709
Show file tree
Hide file tree
Showing 58 changed files with 147 additions and 137 deletions.
3 changes: 3 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[settings]
sections=FUTURE, STDLIB, FIRSTPARTY, THIRDPARTY, LOCALFOLDER
KNOWN_FIRST_PARTY=jinja2, lml, pyecharts_javascripthon, PIL
2 changes: 1 addition & 1 deletion docs/zh-cn/charts_configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
默认控制第一个 y 轴,如没特殊需求无须显示指定。单个为 int 类型而控制多个为 list 类型,如 [0, 1] 表示控制第一个和第二个 x 轴。

额外的 dataZoom 控制条
* is_datazoom_extrashow -> bool
* is_datazoom_extra_show -> bool
是否使用额外区域缩放组件,默认为 False
* datazoom_extra_type -> str
额外区域缩放组件类型,默认为'slider',有'slider', 'inside', 'both'可选
Expand Down
4 changes: 3 additions & 1 deletion format_code.bat
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
pink *.py pyecharts/**/*.py test/*.py
SET FILES=*.py pyecharts/**/*.py test/*.py
lias %FILES% -sp .isort.cfg
pink %FILES%
1 change: 1 addition & 0 deletions format_code.sh
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
lias *.py pyecharts/**/*.py test/*.py -sp .isort.cfg
pink *.py pyecharts/**/*.py test/*.py
6 changes: 3 additions & 3 deletions pyecharts/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
from tempfile import mkstemp

from jinja2 import Markup
from pyecharts_javascripthon.api import TRANSLATOR

import pyecharts.utils as utils
import pyecharts.engine as engine
import pyecharts.constants as constants
import pyecharts.engine as engine
import pyecharts.exceptions as exceptions
import pyecharts.utils as utils
from pyecharts.conf import CURRENT_CONFIG
from pyecharts_javascripthon.api import TRANSLATOR
from pyecharts.echarts.option import get_all_options


Expand Down
2 changes: 1 addition & 1 deletion pyecharts/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import random

from pyecharts.base import Base
import pyecharts.constants as constants
from pyecharts.base import Base


class Chart(Base):
Expand Down
1 change: 0 additions & 1 deletion pyecharts/charts/gauge.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from pyecharts.chart import Chart


DEFAULT_GAUGE_TOOLTIP_FORMATTER = "{a} <br/>{b} : {c}%"


Expand Down
3 changes: 1 addition & 2 deletions pyecharts/charts/geo.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# coding=utf-8
from __future__ import unicode_literals

import json
import codecs
import json

from pyecharts.chart import Chart
from pyecharts.datasets.coordinates import get_coordinate


DEFAULT_GEO_TOOLTIP_FORMATTER = "{b}: {c}"


Expand Down
2 changes: 1 addition & 1 deletion pyecharts/charts/wordcloud.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# coding=utf-8
import random
from pyecharts.chart import Chart

from pyecharts.chart import Chart

SHAPES = (
"cardioid",
Expand Down
2 changes: 0 additions & 2 deletions pyecharts/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
from contextlib import contextmanager

import pyecharts.constants as constants

from pyecharts.js_extensions import EXTENSION_MANAGER


ONLINE_ASSETS_JS = "https://pyecharts.github.io/assets/js/"


Expand Down
4 changes: 2 additions & 2 deletions pyecharts/custom/grid.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# coding=utf-8
import copy

from pyecharts.echarts.option import grid
from pyecharts.constants import PAGE_TITLE
from pyecharts.base import Base
from pyecharts.constants import PAGE_TITLE
from pyecharts.echarts.option import grid
from pyecharts.utils import merge_js_dependencies


Expand Down
3 changes: 2 additions & 1 deletion pyecharts/custom/overlap.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# coding=utf-8

import copy
from pyecharts.constants import PAGE_TITLE

from pyecharts.base import Base
from pyecharts.constants import PAGE_TITLE
from pyecharts.utils import merge_js_dependencies


Expand Down
4 changes: 2 additions & 2 deletions pyecharts/custom/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

from jinja2 import Markup

import pyecharts.utils as utils
import pyecharts.constants as constants
import pyecharts.engine as engine
import pyecharts.utils as utils
from pyecharts.conf import CURRENT_CONFIG
import pyecharts.constants as constants


class Page(object):
Expand Down
2 changes: 1 addition & 1 deletion pyecharts/custom/timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import copy

from pyecharts.constants import PAGE_TITLE
from pyecharts.base import Base
from pyecharts.constants import PAGE_TITLE
from pyecharts.utils import merge_js_dependencies


Expand Down
5 changes: 2 additions & 3 deletions pyecharts/datasets/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
"""
from __future__ import unicode_literals

import json
import codecs
import json

from lml.plugin import PluginManager, PluginInfo
from lml.plugin import PluginInfo, PluginManager

import pyecharts.constants as constants
import pyecharts.exceptions as exceptions
from pyecharts.utils import get_resource_dir, is_ascii


__all__ = [
"search_coordinates_by_filter",
"search_coordinates_by_keyword",
Expand Down
8 changes: 3 additions & 5 deletions pyecharts/engine.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# coding=utf-8
from __future__ import unicode_literals

from jinja2 import Environment, FileSystemLoader, environmentfunction, Markup
from lml.plugin import PluginManager, PluginInfo
from jinja2 import Environment, FileSystemLoader, Markup, environmentfunction
from lml.plugin import PluginInfo, PluginManager
from pyecharts_javascripthon.api import FUNCTION_TRANSLATOR, TRANSLATOR

import pyecharts.conf as conf
import pyecharts.constants as constants
import pyecharts.utils as utils
from pyecharts_javascripthon.api import TRANSLATOR
from pyecharts_javascripthon.api import FUNCTION_TRANSLATOR


LINK_SCRIPT_FORMATTER = '<script type="text/javascript" src="{}"></script>'
EMBED_SCRIPT_FORMATTER = '<script type="text/javascript">\n{}\n</script>'
Expand Down
4 changes: 2 additions & 2 deletions pyecharts/js_extensions.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# coding=utf-8

import os
import json
import codecs
import json
import os

from lml.loader import scan_plugins
from lml.plugin import PluginManager
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

black==18.6b4
pink>0.4.0
lias>0.2.0
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import os
import sys
from shutil import rmtree
from setuptools import setup, find_packages, Command

from setuptools import Command, find_packages, setup

# RELEASE STEPS
# $ python setup.py upload
Expand Down
2 changes: 1 addition & 1 deletion test/test_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from __future__ import unicode_literals

import random
from test.constants import CLOTHES

from pyecharts import Bar
from test.constants import CLOTHES

clothes_v1 = [5, 20, 36, 10, 75, 90]
clothes_v2 = [10, 25, 8, 60, 20, 80]
Expand Down
4 changes: 2 additions & 2 deletions test/test_bar3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# coding=utf-8
from __future__ import unicode_literals

from pyecharts import Bar3D
from nose.tools import eq_
from test.constants import RANGE_COLOR, X_TIME, Y_WEEK

from nose.tools import eq_
from pyecharts import Bar3D

data = [
[0, 0, 5],
Expand Down
14 changes: 6 additions & 8 deletions test/test_base.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
# coding=utf-8
from __future__ import unicode_literals

import json
import os
import sys
import json
from test.constants import CLOTHES
from test.utils import get_default_rendering_file_content

import pandas as pd
import numpy as np

from nose.tools import eq_, raises
from mock import patch, MagicMock

import pandas as pd
import pyecharts.exceptions as exceptions
from mock import MagicMock, patch
from nose.tools import eq_, raises
from pyecharts import Bar, Map, jupyter_image, online
from pyecharts.conf import CURRENT_CONFIG
from test.constants import CLOTHES
from test.utils import get_default_rendering_file_content

TITLE = "柱状图数据堆叠示例"

Expand Down
5 changes: 3 additions & 2 deletions test/test_chart_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

from __future__ import unicode_literals

from pyecharts.base import Base
from pyecharts import Bar, Line, Grid
from test.constants import CLOTHES, WEEK

from nose.tools import eq_
from pyecharts import Bar, Grid, Line
from pyecharts.base import Base

UUID_HEX_LENGTH = 32

Expand Down
4 changes: 1 addition & 3 deletions test/test_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
from __future__ import unicode_literals

from nose.tools import eq_, raises

from pyecharts.conf import _ensure_echarts_is_in_the_front
from pyecharts.conf import PyEchartsConfig
from pyecharts.conf import PyEchartsConfig, _ensure_echarts_is_in_the_front


def test_custom_local_jshost():
Expand Down
1 change: 0 additions & 1 deletion test/test_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import pyecharts.conf as conf
from nose.tools import eq_


DEFAULT_JS_LIBRARIES = dict(
echarts="echarts.min",
echartsgl="echarts-gl.min",
Expand Down
11 changes: 5 additions & 6 deletions test/test_coordinate_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
Test Case for the acccess interface of coordinate dataset
"""
from __future__ import unicode_literals
from nose.tools import eq_, raises
from nose.tools import assert_dict_equal

from nose.tools import assert_dict_equal, eq_, raises
from pyecharts.datasets.coordinates import (
GEO_DATA_BANK,
DefaultChinaDataBank,
get_coordinate,
search_coordinates_by_region_and_keyword,
search_coordinates_by_keyword,
search_coordinates_by_filter,
DefaultChinaDataBank,
GEO_DATA_BANK,
search_coordinates_by_keyword,
search_coordinates_by_region_and_keyword,
)
from pyecharts.exceptions import RegionNotFound

Expand Down
15 changes: 12 additions & 3 deletions test/test_custom.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
#!/usr/bin/env python
# coding=utf-8
from __future__ import unicode_literals
from random import randint

from pyecharts import Bar, Line, Scatter, EffectScatter
from pyecharts import Grid, Timeline, Overlap, Page
from random import randint
from test.constants import CLOTHES, WEEK

from pyecharts import (
Bar,
EffectScatter,
Grid,
Line,
Overlap,
Page,
Scatter,
Timeline,
)


def test_page_grid_timeline_overlap():
# Grid
Expand Down
8 changes: 3 additions & 5 deletions test/test_custom_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
from __future__ import unicode_literals

import codecs
from test.constants import CLOTHES, RANGE_COLOR

from pyecharts import Bar, Scatter3D
from pyecharts import Page
from pyecharts.conf import CURRENT_CONFIG
from pyecharts.conf import configure
from test.constants import RANGE_COLOR, CLOTHES
from pyecharts import Bar, Page, Scatter3D
from pyecharts.conf import CURRENT_CONFIG, configure


def create_three():
Expand Down
7 changes: 4 additions & 3 deletions test/test_events.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# coding=utf-8
from __future__ import unicode_literals

from pyecharts import Map
import pyecharts.echarts.events as events
from test.utils import get_default_rendering_file_content

from pyecharts_javascripthon.dom import alert

from test.utils import get_default_rendering_file_content
import pyecharts.echarts.events as events
from pyecharts import Map


def on_click(params):
Expand Down
3 changes: 2 additions & 1 deletion test/test_funnel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
# coding=utf-8
from __future__ import unicode_literals

from pyecharts import Funnel
from test.constants import CLOTHES

from pyecharts import Funnel

prices = [20, 40, 60, 80, 100, 120]


Expand Down
2 changes: 1 addition & 1 deletion test/test_geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# coding=utf-8
from __future__ import unicode_literals

from nose.tools import assert_raises, raises
from pyecharts import Geo, Style
from nose.tools import raises, assert_raises

style = Style(
title_color="#fff",
Expand Down
1 change: 0 additions & 1 deletion test/test_geolines.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from __future__ import unicode_literals

from nose.tools import assert_raises

from pyecharts import GeoLines, Style
from pyecharts.datasets.coordinates import search_coordinates_by_keyword

Expand Down
Loading

0 comments on commit d2c4709

Please sign in to comment.