Skip to content

Commit f3e2286

Browse files
author
Nathaniel Henry
committed
Rewrite the close_map() plotly dicts as literals to satisfy ruff C408.
1 parent e6fa19c commit f3e2286

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

src/closecity/map.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ def close_map(
6060

6161
if "Point" in geom_type:
6262
if fv is not None:
63-
marker = dict(size = size, color = fv, colorscale = palette,
64-
reversescale = reverse, showscale = True,
65-
colorbar = dict(title = fill))
63+
marker = {"size": size, "color": fv, "colorscale": palette,
64+
"reversescale": reverse, "showscale": True,
65+
"colorbar": {"title": fill}}
6666
else:
6767
marker_color = color if hl is None else [
6868
color if h else "#888888" for h in hl
6969
]
70-
marker = dict(size = size, color = marker_color)
70+
marker = {"size": size, "color": marker_color}
7171
fig = go.Figure(go.Scattermapbox(
7272
lat = g.geometry.y.tolist(), lon = g.geometry.x.tolist(),
7373
mode = "markers", marker = marker,
@@ -79,16 +79,16 @@ def close_map(
7979
g = g.reset_index(drop = True)
8080
g["_id"] = [str(i) for i in range(len(g))]
8181
geojson = json.loads(g[["_id", "geometry"]].to_json())
82-
common = dict(
83-
geojson = geojson, locations = g["_id"].tolist(),
84-
featureidkey = "properties._id",
85-
marker = dict(opacity = opacity, line = dict(width = 0)),
86-
text = hover, hoverinfo = "text" if hover else "none",
87-
)
82+
common = {
83+
"geojson": geojson, "locations": g["_id"].tolist(),
84+
"featureidkey": "properties._id",
85+
"marker": {"opacity": opacity, "line": {"width": 0}},
86+
"text": hover, "hoverinfo": "text" if hover else "none",
87+
}
8888
if fv is not None:
8989
trace = go.Choroplethmapbox(
9090
z = fv, colorscale = palette, reversescale = reverse,
91-
showscale = True, colorbar = dict(title = fill), **common)
91+
showscale = True, colorbar = {"title": fill}, **common)
9292
else:
9393
z = [1] * len(g) if hl is None else [int(h) for h in hl]
9494
colorscale = ([[0, color], [1, color]] if hl is None
@@ -98,7 +98,7 @@ def close_map(
9898
fig = go.Figure(trace)
9999

100100
fig.update_layout(
101-
mapbox = dict(style = "carto-positron", zoom = zoom, center = center),
102-
margin = dict(l = 0, r = 0, t = 0, b = 0),
101+
mapbox = {"style": "carto-positron", "zoom": zoom, "center": center},
102+
margin = {"l": 0, "r": 0, "t": 0, "b": 0},
103103
)
104104
return fig

0 commit comments

Comments
 (0)