Skip to content

Commit 7c1fa69

Browse files
authored
Merge pull request #504 from ocefpaf/fix_lints
Fix lints
2 parents a5d81e9 + f92303e commit 7c1fa69

File tree

3 files changed

+42
-34
lines changed

3 files changed

+42
-34
lines changed

folium/features.py

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55
66
Extra features Elements.
77
"""
8-
from jinja2 import Template
98
import json
109

11-
from branca.utilities import (_parse_size,
12-
_locations_mirror, _locations_tolist, image_to_url,
13-
text_type, binary_type,
14-
none_min, none_max, iter_points,
15-
)
16-
from branca.element import Element, Figure, JavascriptLink, CssLink, MacroElement
10+
from jinja2 import Template
11+
from six import text_type
12+
13+
from branca.utilities import (
14+
_parse_size, _locations_mirror, _locations_tolist, image_to_url,
15+
binary_type, none_min, none_max, iter_points,
16+
)
17+
from branca.element import (Element, Figure, JavascriptLink, CssLink,
18+
MacroElement)
1719
from branca.colormap import LinearColormap
1820

1921
from .map import Layer, Icon, Marker, Popup, FeatureGroup
@@ -762,13 +764,14 @@ def __init__(self, bounds, color='black', weight=1, fill_color='black',
762764
self.fill_opacity = fill_opacity
763765
self._template = Template(u"""
764766
{% macro script(this, kwargs) %}
765-
var {{this.get_name()}} = L.rectangle([[{{this.location[0]}}, {{this.location[1]}}],
766-
[{{this.location[2]}}, {{this.location[3]}}]],
767+
var {{this.get_name()}} = L.rectangle(
768+
[[{{this.location[0]}},{{this.location[1]}}],
769+
[{{this.location[2]}},{{this.location[3]}}]],
767770
{
768-
color:'{{ this.color }}',
769-
fillColor:'{{ this.fill_color }}',
770-
fillOpacity:{{ this.fill_opacity }},
771-
weight:{{ this.weight }}
771+
color: '{{ this.color }}',
772+
fillColor: '{{ this.fill_color }}',
773+
fillOpacity: {{ this.fill_opacity }},
774+
weight: {{ this.weight }}
772775
}).addTo({{this._parent.get_name()}});
773776
774777
{% endmacro %}
@@ -799,18 +802,21 @@ def __init__(self, locations, color='black', weight=1, fill_color='black',
799802
-------
800803
folium.features.Polygon object
801804
802-
Example
803-
-------
804-
>>> loc= [[35.6762, 139.7795],
805-
[35.6718, 139.7831],
806-
[35.6767, 139.7868],
807-
[35.6795, 139.7824],
808-
[35.6787, 139.7791]]
809-
Polygon(loc, color="blue", weight=10, fill_color="red",
810-
fill_opacity=0.5, popup="Tokyo, Japan"))
805+
Examples
806+
--------
807+
>>> loc = [[35.6762, 139.7795],
808+
... [35.6718, 139.7831],
809+
... [35.6767, 139.7868],
810+
... [35.6795, 139.7824],
811+
... [35.6787, 139.7791]]
812+
>>> Polygon(loc, color="blue", weight=10, fill_color="red",
813+
... fill_opacity=0.5, popup="Tokyo, Japan"))
814+
811815
"""
812-
super(Polygon, self).__init__((_locations_mirror(locations) if not latlon else
813-
_locations_tolist(locations)), popup=popup)
816+
super(Polygon, self).__init__((
817+
_locations_mirror(locations) if not latlon else
818+
_locations_tolist(locations)), popup=popup
819+
)
814820
self._name = 'Polygon'
815821
self.color = color
816822
self.weight = weight
@@ -1096,12 +1102,11 @@ class ColorLine(FeatureGroup):
10961102
The list of segments colors.
10971103
It must have length equal to `len(positions)-1`.
10981104
colormap: branca.colormap.Colormap or list or tuple
1099-
The colormap to use.
1100-
If a list or tuple of colors is provided, a LinearColormap will be created
1101-
from it.
1105+
The colormap to use. If a list or tuple of colors is provided,
1106+
a LinearColormap will be created from it.
11021107
nb_steps: int, default 12
1103-
To have lighter output, the colormap will be discretized to that number
1104-
of colors.
1108+
To have lighter output the colormap will be discretized
1109+
to that number of colors.
11051110
opacity: float, default 1
11061111
Line opacity, scale 0-1
11071112
weight: int, default 2
@@ -1133,7 +1138,8 @@ def __init__(self, positions, colors, colormap=None, nb_steps=12,
11331138
else:
11341139
cm = colormap
11351140
out = {}
1136-
for (lat1, lng1), (lat2, lng2), color in zip(positions[:-1], positions[1:], colors):
1141+
for (lat1, lng1), (lat2, lng2), color in zip(positions[:-1], positions[1:], colors): # noqa
11371142
out.setdefault(cm(color), []).append([[lat1, lng1], [lat2, lng2]])
11381143
for key, val in out.items():
1139-
self.add_child(MultiPolyLine(val, color=key, weight=weight, opacity=opacity))
1144+
self.add_child(MultiPolyLine(val, color=key,
1145+
weight=weight, opacity=opacity))

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
Jinja2
22
branca
3+
six

tests/test_folium.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
import branca.element
2626

2727
from folium.map import Popup, Marker, FitBounds, FeatureGroup
28-
from folium.features import GeoJson, TopoJson, PolyLine, MultiPolyLine, RectangleMarker, Polygon
28+
from folium.features import (GeoJson, TopoJson, PolyLine, MultiPolyLine,
29+
RectangleMarker, Polygon)
2930
from folium.plugins import ImageOverlay
3031

3132
rootpath = os.path.abspath(os.path.dirname(__file__))
@@ -455,12 +456,12 @@ def test_geo_json_str(self):
455456

456457
out = ''.join(self.map._parent.render().split())
457458

458-
# Verify the geo_json object
459+
# Verify the geo_json object.
459460
obj_temp = jinja2.Template("""
460461
var {{ this.get_name() }} = L.geoJson({{ this.style_data() }})
461462
.addTo({{ this._parent.get_name() }});
462463
{{ this.get_name() }}.setStyle(function(feature) {return feature.properties.style;});
463-
""")
464+
""") # noqa
464465
obj = obj_temp.render(this=geo_json, json=json)
465466
assert ''.join(obj.split())[:-1] in out
466467

0 commit comments

Comments
 (0)