Browse Source

Fix lint

master
Florian Mounier 6 years ago
parent
commit
d2134581f0
  1. 42
      .style.yapf
  2. 2
      Makefile
  3. 11
      pygal/graph/base.py
  4. 12
      pygal/graph/box.py
  5. 11
      pygal/graph/graph.py
  6. 6
      pygal/graph/radar.py
  7. 45
      pygal/test/test_date.py
  8. 8
      pygal/test/test_interpolate.py
  9. 5
      setup.cfg

42
.style.yapf

@ -1,13 +1,6 @@
[style]
based_on_style = pep8
# █████ ██ ██
# ██ ██ ██ ██
# ███████ ██ ██
# ██ ██ ██ ██
# ██ ██ ███████ ███████
# Align closing bracket with visual indentation.
# align_closing_bracket_with_visual_indent=True
@ -23,6 +16,13 @@ based_on_style = pep8
# Allow lambdas to be formatted on more than one line.
# allow_multiline_lambdas=False
# Allow splits before the dictionary value.
# allow_split_before_dict_value=True
# Number of blank lines surrounding top-level function and class
# definitions.
# blank_lines_around_top_level_definition=2
# Insert a blank line before a class-level docstring.
# blank_line_before_class_docstring=False
@ -138,6 +138,10 @@ join_multiple_lines=False
# after.
# split_before_bitwise_operator=True
# Split before the closing bracket if a list or dict literal doesn't fit on
# a single line.
# split_before_closing_bracket=True
# Split before a dictionary or set generator (comp_for). For example, note
# the split before the 'for':
#
@ -147,6 +151,10 @@ join_multiple_lines=False
# }
# split_before_dict_set_generator=True
# Split after the opening paren which surrounds an expression if it doesn't
# fit on a single line.
split_before_expression_after_opening_paren=True
# If an argument / parameter list is going to be split, then split before
# the first argument.
split_before_first_argument=True
@ -158,6 +166,22 @@ split_before_first_argument=True
# Split named assignments onto individual lines.
# split_before_named_assigns=True
# Set to True to split list comprehensions and generators that have
# non-trivial expressions and multiple clauses before each of these
# clauses. For example:
#
# result = [
# a_long_var + 100 for a_long_var in xrange(1000)
# if a_long_var % 10]
#
# would reformat to something like:
#
# result = [
# a_long_var + 100
# for a_long_var in xrange(1000)
# if a_long_var % 10]
split_complex_comprehension=False
# The penalty for splitting right after the opening bracket.
# split_penalty_after_opening_bracket=30
@ -171,6 +195,10 @@ split_before_first_argument=True
# operators.
# split_penalty_bitwise_operator=300
# The penalty for splitting a list comprehension or generator
# expression.
# split_penalty_comprehension=80
# The penalty for characters over the column limit.
# split_penalty_excess_character=4500

2
Makefile

@ -5,7 +5,7 @@ all: install lint check check-outdated
install:
test -d $(VENV) || virtualenv $(VENV) -p $(PYTHON_VERSION)
$(PIP) install --upgrade --no-cache --no-binary :all: pip setuptools -e .[test,docs] devcore
$(PIP) install --upgrade --upgrade-strategy eager --no-cache --no-binary :all: pip setuptools -e .[test,docs] devcore
clean:
rm -fr $(VENV)

11
pygal/graph/base.py

@ -66,8 +66,8 @@ class BaseGraph(object):
def __getattribute__(self, name):
"""Get an attribute from the class or from the state if there is one"""
if name.startswith('__') or name == 'state' or getattr(
self, 'state', None
) is None or name not in self.state.__dict__:
self, 'state',
None) is None or name not in self.state.__dict__:
return super(BaseGraph, self).__getattribute__(name)
return getattr(self.state, name)
@ -187,10 +187,9 @@ class BaseGraph(object):
self.series = self.prepare_values([
rs for rs in self.raw_series if not rs[1].get('secondary')
]) or []
self.secondary_series = self.prepare_values(
[rs for rs in self.raw_series
if rs[1].get('secondary')], len(self.series)
) or []
self.secondary_series = self.prepare_values([
rs for rs in self.raw_series if rs[1].get('secondary')
], len(self.series)) or []
self.horizontal = getattr(self, 'horizontal', False)
self.svg = Svg(self)
self._x_labels = None

12
pygal/graph/box.py

@ -136,9 +136,7 @@ class Box(Graph):
coords=[(xs, self.view.y(whisker)),
(xe, self.view.y(whisker))],
class_='reactive tooltip-trigger',
attrib={
'stroke-width': 3
}
attrib={'stroke-width': 3}
), metadata
)
@ -149,9 +147,7 @@ class Box(Graph):
coords=[(left_edge + width / 2, self.view.y(quartiles[0])),
(left_edge + width / 2, self.view.y(quartiles[1]))],
class_='reactive tooltip-trigger',
attrib={
'stroke-width': 2
}
attrib={'stroke-width': 2}
), metadata
)
alter(
@ -160,9 +156,7 @@ class Box(Graph):
coords=[(left_edge + width / 2, self.view.y(quartiles[4])),
(left_edge + width / 2, self.view.y(quartiles[3]))],
class_='reactive tooltip-trigger',
attrib={
'stroke-width': 2
}
attrib={'stroke-width': 2}
), metadata
)

11
pygal/graph/graph.py

@ -125,9 +125,7 @@ class Graph(PublicApi):
self.nodes['tooltip_overlay'],
transform='translate(0 0)',
style="opacity: 0",
**{
'class': 'tooltip'
}
**{'class': 'tooltip'}
)
self.svg.node(
@ -137,9 +135,7 @@ class Graph(PublicApi):
ry=self.tooltip_border_radius,
width=0,
height=0,
**{
'class': 'tooltip-box'
}
**{'class': 'tooltip-box'}
)
self.svg.node(self.nodes['tooltip'], 'g', class_='text')
@ -159,7 +155,8 @@ class Graph(PublicApi):
first_label_position = self.view.x(self._x_labels[0][1]) or 0
last_label_position = self.view.x(self._x_labels[-1][1]) or 0
available_space = (last_label_position - first_label_position
) / (len(self._x_labels) - 1)
) / len(self._x_labels) - 1
truncation = reverse_text_len(
available_space, self.style.label_font_size
)

6
pygal/graph/radar.py

@ -155,9 +155,9 @@ class Radar(Line):
text.text = label
if self.y_label_rotation:
text.attrib['transform'] = "rotate(%d %f %f)" % (
self.y_label_rotation, x, y
)
text.attrib[
'transform'
] = "rotate(%d %f %f)" % (self.y_label_rotation, x, y)
self.svg.node(
guides,

45
pygal/test/test_date.py

@ -34,11 +34,8 @@ def test_date():
)
q = date_chart.render_pyquery()
assert list(map(lambda t: t.split(' ')[0],
q(".axis.x text").map(texts))) == [
'2013-01-12', '2013-01-24', '2013-02-04', '2013-02-16'
]
dates = list(map(lambda t: t.split(' ')[0], q(".axis.x text").map(texts)))
assert dates == ['2013-01-12', '2013-01-24', '2013-02-04', '2013-02-16']
def test_time():
@ -50,12 +47,11 @@ def test_time():
)
q = time_chart.render_pyquery()
assert list(map(lambda t: t.split(' ')[0],
q(".axis.x text").map(texts))) == [
'02:46:40', '05:33:20', '08:20:00', '11:06:40',
'13:53:20', '16:40:00', '19:26:40'
]
dates = list(map(lambda t: t.split(' ')[0], q(".axis.x text").map(texts)))
assert dates == [
'02:46:40', '05:33:20', '08:20:00', '11:06:40', '13:53:20', '16:40:00',
'19:26:40'
]
def test_datetime():
@ -69,12 +65,11 @@ def test_datetime():
)
q = datetime_chart.render_pyquery()
assert list(map(lambda t: t.split(' ')[0],
q(".axis.x text").map(texts))) == [
'2013-01-12T14:13:20', '2013-01-24T04:00:00',
'2013-02-04T17:46:40', '2013-02-16T07:33:20'
]
dates = list(map(lambda t: t.split(' ')[0], q(".axis.x text").map(texts)))
assert dates == [
'2013-01-12T14:13:20', '2013-01-24T04:00:00', '2013-02-04T17:46:40',
'2013-02-16T07:33:20'
]
def test_timedelta():
@ -107,11 +102,11 @@ def test_date_xrange():
datey.xrange = (date(2013, 1, 1), date(2013, 3, 1))
q = datey.render_pyquery()
assert list(map(lambda t: t.split(' ')[0],
q(".axis.x text").map(texts))) == [
'2013-01-01', '2013-01-12', '2013-01-24', '2013-02-04',
'2013-02-16', '2013-02-27'
]
dates = list(map(lambda t: t.split(' ')[0], q(".axis.x text").map(texts)))
assert dates == [
'2013-01-01', '2013-01-12', '2013-01-24', '2013-02-04', '2013-02-16',
'2013-02-27'
]
def test_date_labels():
@ -125,10 +120,8 @@ def test_date_labels():
datey.x_labels = [date(2013, 1, 1), date(2013, 2, 1), date(2013, 3, 1)]
q = datey.render_pyquery()
assert list(map(lambda t: t.split(' ')[0],
q(".axis.x text").map(texts))) == [
'2013-01-01', '2013-02-01', '2013-03-01'
]
dates = list(map(lambda t: t.split(' ')[0], q(".axis.x text").map(texts)))
assert dates == ['2013-01-01', '2013-02-01', '2013-03-01']
def test_utc_timestamping():

8
pygal/test/test_interpolate.py

@ -71,9 +71,7 @@ def test_hermite_finite(Chart, datas):
"""Test hermite finite difference interpolation"""
chart = Chart(
interpolate='hermite',
interpolation_parameters={
'type': 'finite_difference'
}
interpolation_parameters={'type': 'finite_difference'}
)
chart = make_data(chart, datas)
assert chart.render()
@ -96,9 +94,7 @@ def test_hermite_catmull_rom(Chart, datas):
"""Test hermite catmull rom interpolation"""
chart = Chart(
interpolate='hermite',
interpolation_parameters={
'type': 'catmull_rom'
}
interpolation_parameters={'type': 'catmull_rom'}
)
chart = make_data(chart, datas)
assert chart.render()

5
setup.cfg

@ -1,9 +1,12 @@
[wheel]
universal = 1
[pycodestyle]
ignore = E731,E402,E741,W503
[tool:pytest]
flake8-ignore =
*.py E731 E402 E741
*.py E731 E402 E741 W503
pygal/__init__.py F401
pygal/_compat.py F821 F401
docs/conf.py ALL

Loading…
Cancel
Save