Browse Source

Fix lint

master
Florian Mounier 7 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] [style]
based_on_style = pep8 based_on_style = pep8
# █████ ██ ██
# ██ ██ ██ ██
# ███████ ██ ██
# ██ ██ ██ ██
# ██ ██ ███████ ███████
# Align closing bracket with visual indentation. # Align closing bracket with visual indentation.
# align_closing_bracket_with_visual_indent=True # 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 lambdas to be formatted on more than one line.
# allow_multiline_lambdas=False # 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. # Insert a blank line before a class-level docstring.
# blank_line_before_class_docstring=False # blank_line_before_class_docstring=False
@ -138,6 +138,10 @@ join_multiple_lines=False
# after. # after.
# split_before_bitwise_operator=True # 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 # Split before a dictionary or set generator (comp_for). For example, note
# the split before the 'for': # the split before the 'for':
# #
@ -147,6 +151,10 @@ join_multiple_lines=False
# } # }
# split_before_dict_set_generator=True # 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 # If an argument / parameter list is going to be split, then split before
# the first argument. # the first argument.
split_before_first_argument=True split_before_first_argument=True
@ -158,6 +166,22 @@ split_before_first_argument=True
# Split named assignments onto individual lines. # Split named assignments onto individual lines.
# split_before_named_assigns=True # 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. # The penalty for splitting right after the opening bracket.
# split_penalty_after_opening_bracket=30 # split_penalty_after_opening_bracket=30
@ -171,6 +195,10 @@ split_before_first_argument=True
# operators. # operators.
# split_penalty_bitwise_operator=300 # 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. # The penalty for characters over the column limit.
# split_penalty_excess_character=4500 # split_penalty_excess_character=4500

2
Makefile

@ -5,7 +5,7 @@ all: install lint check check-outdated
install: install:
test -d $(VENV) || virtualenv $(VENV) -p $(PYTHON_VERSION) 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: clean:
rm -fr $(VENV) rm -fr $(VENV)

11
pygal/graph/base.py

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

12
pygal/graph/box.py

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

11
pygal/graph/graph.py

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

6
pygal/graph/radar.py

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

45
pygal/test/test_date.py

@ -34,11 +34,8 @@ def test_date():
) )
q = date_chart.render_pyquery() q = date_chart.render_pyquery()
dates = list(map(lambda t: t.split(' ')[0], q(".axis.x text").map(texts)))
assert list(map(lambda t: t.split(' ')[0], assert dates == ['2013-01-12', '2013-01-24', '2013-02-04', '2013-02-16']
q(".axis.x text").map(texts))) == [
'2013-01-12', '2013-01-24', '2013-02-04', '2013-02-16'
]
def test_time(): def test_time():
@ -50,12 +47,11 @@ def test_time():
) )
q = time_chart.render_pyquery() q = time_chart.render_pyquery()
dates = list(map(lambda t: t.split(' ')[0], q(".axis.x text").map(texts)))
assert list(map(lambda t: t.split(' ')[0], assert dates == [
q(".axis.x text").map(texts))) == [ '02:46:40', '05:33:20', '08:20:00', '11:06:40', '13:53:20', '16:40:00',
'02:46:40', '05:33:20', '08:20:00', '11:06:40', '19:26:40'
'13:53:20', '16:40:00', '19:26:40' ]
]
def test_datetime(): def test_datetime():
@ -69,12 +65,11 @@ def test_datetime():
) )
q = datetime_chart.render_pyquery() q = datetime_chart.render_pyquery()
dates = list(map(lambda t: t.split(' ')[0], q(".axis.x text").map(texts)))
assert list(map(lambda t: t.split(' ')[0], assert dates == [
q(".axis.x text").map(texts))) == [ '2013-01-12T14:13:20', '2013-01-24T04:00:00', '2013-02-04T17:46:40',
'2013-01-12T14:13:20', '2013-01-24T04:00:00', '2013-02-16T07:33:20'
'2013-02-04T17:46:40', '2013-02-16T07:33:20' ]
]
def test_timedelta(): def test_timedelta():
@ -107,11 +102,11 @@ def test_date_xrange():
datey.xrange = (date(2013, 1, 1), date(2013, 3, 1)) datey.xrange = (date(2013, 1, 1), date(2013, 3, 1))
q = datey.render_pyquery() q = datey.render_pyquery()
assert list(map(lambda t: t.split(' ')[0], dates = list(map(lambda t: t.split(' ')[0], q(".axis.x text").map(texts)))
q(".axis.x text").map(texts))) == [ assert dates == [
'2013-01-01', '2013-01-12', '2013-01-24', '2013-02-04', '2013-01-01', '2013-01-12', '2013-01-24', '2013-02-04', '2013-02-16',
'2013-02-16', '2013-02-27' '2013-02-27'
] ]
def test_date_labels(): 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)] datey.x_labels = [date(2013, 1, 1), date(2013, 2, 1), date(2013, 3, 1)]
q = datey.render_pyquery() q = datey.render_pyquery()
assert list(map(lambda t: t.split(' ')[0], dates = list(map(lambda t: t.split(' ')[0], q(".axis.x text").map(texts)))
q(".axis.x text").map(texts))) == [ assert dates == ['2013-01-01', '2013-02-01', '2013-03-01']
'2013-01-01', '2013-02-01', '2013-03-01'
]
def test_utc_timestamping(): 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""" """Test hermite finite difference interpolation"""
chart = Chart( chart = Chart(
interpolate='hermite', interpolate='hermite',
interpolation_parameters={ interpolation_parameters={'type': 'finite_difference'}
'type': 'finite_difference'
}
) )
chart = make_data(chart, datas) chart = make_data(chart, datas)
assert chart.render() assert chart.render()
@ -96,9 +94,7 @@ def test_hermite_catmull_rom(Chart, datas):
"""Test hermite catmull rom interpolation""" """Test hermite catmull rom interpolation"""
chart = Chart( chart = Chart(
interpolate='hermite', interpolate='hermite',
interpolation_parameters={ interpolation_parameters={'type': 'catmull_rom'}
'type': 'catmull_rom'
}
) )
chart = make_data(chart, datas) chart = make_data(chart, datas)
assert chart.render() assert chart.render()

5
setup.cfg

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

Loading…
Cancel
Save