diff --git a/demo/moulinrouge.py b/demo/moulinrouge.py index 3ab1fe96..e8f76a2b 100755 --- a/demo/moulinrouge.py +++ b/demo/moulinrouge.py @@ -36,7 +36,7 @@ handler.setLevel(logging.DEBUG) app.logger.setLevel(logging.DEBUG) logging.getLogger('werkzeug').setLevel(logging.DEBUG) -except: +except Exception: pass try: diff --git a/demo/moulinrouge/__init__.py b/demo/moulinrouge/__init__.py index a42ccf1d..3ed919b8 100644 --- a/demo/moulinrouge/__init__.py +++ b/demo/moulinrouge/__init__.py @@ -16,18 +16,19 @@ # # You should have received a copy of the GNU Lesser General Public License # along with pygal. If not, see . -from flask import Flask, render_template, Response, request +import pickle +import random +import string +from base64 import urlsafe_b64decode as b64decode +from base64 import urlsafe_b64encode as b64encode + +from flask import Flask, Response, render_template, request + import pygal from pygal.config import Config -from pygal.util import cut from pygal.etree import etree -from pygal.style import styles, parametric_styles -from base64 import ( - urlsafe_b64encode as b64encode, urlsafe_b64decode as b64decode -) -import string -import random -import pickle +from pygal.style import parametric_styles, styles +from pygal.util import cut def get(type): diff --git a/demo/moulinrouge/tests.py b/demo/moulinrouge/tests.py index 38172666..1937c43b 100644 --- a/demo/moulinrouge/tests.py +++ b/demo/moulinrouge/tests.py @@ -4,10 +4,30 @@ from random import choice, randint from flask import abort + from pygal import ( - CHARTS_BY_NAME, XY, Bar, Box, Config, DateLine, DateTimeLine, Dot, Funnel, - Gauge, Histogram, HorizontalBar, Line, Pie, Pyramid, Radar, SolidGauge, - StackedBar, StackedLine, TimeLine, Treemap, formatters, stats + CHARTS_BY_NAME, + XY, + Bar, + Box, + Config, + DateLine, + DateTimeLine, + Dot, + Funnel, + Gauge, + Histogram, + Line, + Pie, + Pyramid, + Radar, + SolidGauge, + StackedBar, + StackedLine, + TimeLine, + Treemap, + formatters, + stats, ) from pygal.colors import rotate from pygal.graph.horizontal import HorizontalGraph @@ -706,7 +726,7 @@ def test_swissmap(): smap.add( 'links', [{ 'value': ('kt-vs', 10), - 'label': '\o/', + 'label': r'\o/', 'xlink': 'http://google.com?q=69' }, { 'value': ('bt', 20), @@ -731,7 +751,7 @@ def test_frenchmapregions(): fmap.add( 'links', [{ 'value': ('02', 10), - 'label': '\o/', + 'label': r'\o/', 'xlink': 'http://google.com?q=69' }, { 'value': ('72', 20), @@ -1029,7 +1049,7 @@ def test_rotations_for(chart): @app.route('/test/datetimeline') def test_datetimeline(): line = DateTimeLine() - from datetime import timezone, timedelta + from datetime import timedelta, timezone tz7 = timezone(timedelta(hours=7), 'GMT +7') tzn4 = timezone(timedelta(hours=-4), 'GMT -4') @@ -1069,7 +1089,6 @@ def test_order_min(): @app.route('/test/custom_css_file') def test_custom_css_file(): - from tempfile import NamedTemporaryFile custom_css = ''' {{ id }}text { fill: green; diff --git a/docs/ext/pygal_sphinx_directives.py b/docs/ext/pygal_sphinx_directives.py index 8dbd3597..c8ef082a 100644 --- a/docs/ext/pygal_sphinx_directives.py +++ b/docs/ext/pygal_sphinx_directives.py @@ -20,10 +20,11 @@ from traceback import format_exc, print_exc import docutils.core -import pygal from docutils.parsers.rst import Directive from sphinx.directives.code import CodeBlock +import pygal + # Patch default style pygal.config.Config.style.value = pygal.style.RotateStyle( @@ -76,7 +77,7 @@ def run(self): ) ] if self.render_fix: - rv = scope['rv'] + _rv = scope['rv'] else: chart = None for key, value in scope.items(): diff --git a/perf.py b/perf.py index ec40037c..9a903eab 100644 --- a/perf.py +++ b/perf.py @@ -66,9 +66,10 @@ def cht(s): if '--mem' in sys.argv: _TWO_20 = float(2 ** 20) + import linecache import os + import psutil - import linecache pid = os.getpid() process = psutil.Process(pid) import gc diff --git a/pygal/config.py b/pygal/config.py index 69f12b82..2c66324e 100644 --- a/pygal/config.py +++ b/pygal/config.py @@ -64,8 +64,8 @@ def __repr__(self): This is a hack to generate doc from inner doc """ return """ - Type: %s%s      - Default: %r      + Type: %s%s + Default: %r %s%s """ % ( self.type.__name__, (' of %s' % self.subtype.__name__) diff --git a/pygal/graph/graph.py b/pygal/graph/graph.py index 0aecbfe6..048c3056 100644 --- a/pygal/graph/graph.py +++ b/pygal/graph/graph.py @@ -25,8 +25,18 @@ from pygal.graph.public import PublicApi from pygal.interpolate import INTERPOLATIONS from pygal.util import ( - cached_property, compute_scale, cut, decorate, filter_kwargs, get_text_box, - get_texts_box, majorize, rad, reverse_text_len, split_title, truncate + cached_property, + compute_scale, + cut, + decorate, + filter_kwargs, + get_text_box, + get_texts_box, + majorize, + rad, + reverse_text_len, + split_title, + truncate, ) from pygal.view import LogView, ReverseView, View, XYLogView diff --git a/pygal/svg.py b/pygal/svg.py index d246a1c7..bf9565b1 100644 --- a/pygal/svg.py +++ b/pygal/svg.py @@ -32,8 +32,13 @@ from pygal._compat import to_str, u from pygal.etree import etree from pygal.util import ( - coord_abs_project, coord_diff, coord_dual, coord_format, coord_project, - minify_css, template + coord_abs_project, + coord_diff, + coord_dual, + coord_format, + coord_project, + minify_css, + template, ) nearly_2pi = 2 * pi - .00001 diff --git a/pygal/test/test_colors.py b/pygal/test/test_colors.py index 5913efe6..3d09c870 100644 --- a/pygal/test/test_colors.py +++ b/pygal/test/test_colors.py @@ -21,8 +21,15 @@ from __future__ import division from pygal.colors import ( - darken, desaturate, hsl_to_rgb, lighten, parse_color, rgb_to_hsl, rotate, - saturate, unparse_color + darken, + desaturate, + hsl_to_rgb, + lighten, + parse_color, + rgb_to_hsl, + rotate, + saturate, + unparse_color, ) diff --git a/pygal/test/test_config.py b/pygal/test/test_config.py index 758a2eca..a9996d26 100644 --- a/pygal/test/test_config.py +++ b/pygal/test/test_config.py @@ -21,10 +21,29 @@ from tempfile import NamedTemporaryFile from pygal import ( - XY, Bar, Box, Config, DateLine, DateTimeLine, Dot, Funnel, Gauge, - Histogram, HorizontalBar, HorizontalLine, HorizontalStackedBar, - HorizontalStackedLine, Line, Pie, Pyramid, Radar, SolidGauge, - TimeDeltaLine, TimeLine, Treemap, formatters + XY, + Bar, + Box, + Config, + DateLine, + DateTimeLine, + Dot, + Funnel, + Gauge, + Histogram, + HorizontalBar, + HorizontalLine, + HorizontalStackedBar, + HorizontalStackedLine, + Line, + Pie, + Pyramid, + Radar, + SolidGauge, + TimeDeltaLine, + TimeLine, + Treemap, + formatters, ) from pygal._compat import _ellipsis, u from pygal.graph.dual import Dual diff --git a/pygal/test/test_style.py b/pygal/test/test_style.py index 91b8d388..72778d8f 100644 --- a/pygal/test/test_style.py +++ b/pygal/test/test_style.py @@ -20,8 +20,12 @@ from pygal import Line from pygal.style import ( - DarkenStyle, DesaturateStyle, LightenStyle, LightStyle, RotateStyle, - SaturateStyle + DarkenStyle, + DesaturateStyle, + LightenStyle, + LightStyle, + RotateStyle, + SaturateStyle, ) STYLES = LightenStyle, DarkenStyle, SaturateStyle, DesaturateStyle, RotateStyle diff --git a/pygal/test/test_util.py b/pygal/test/test_util.py index f22806b7..769225a1 100644 --- a/pygal/test/test_util.py +++ b/pygal/test/test_util.py @@ -24,8 +24,14 @@ from pygal._compat import _ellipsis, u from pygal.util import ( - _swap_curly, majorize, mergextend, minify_css, round_to_float, - round_to_int, template, truncate + _swap_curly, + majorize, + mergextend, + minify_css, + round_to_float, + round_to_int, + template, + truncate, )