Skip to content

Commit 5ae36fa

Browse files
committed
Fixes for flake8
1 parent 586e672 commit 5ae36fa

File tree

3 files changed

+20
-22
lines changed

3 files changed

+20
-22
lines changed

examples/outputs/app.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import warnings
22

3-
import pandas as pd
43
import numpy as np
5-
4+
import pandas as pd
5+
from htmltools import HTML, head_content
66
from shiny import *
7+
78
from shinywidgets import *
8-
from htmltools import head_content, HTML
99

1010
# TODO: jupyter_bokeh assumes this additional JS has been loaded into the
1111
# (in a notebook, this comes in via bokeh.io.output_notebook()).
@@ -18,7 +18,7 @@
1818

1919
bokeh_dependency = head_content(HTML(Resources(mode="inline").render()))
2020
except ImportError:
21-
warnings.warn("Could not import bokeh")
21+
warnings.warn("Could not import bokeh", stacklevel=2)
2222

2323

2424
app_ui = ui.page_fluid(
@@ -149,7 +149,7 @@ def _():
149149
@output(id="bqplot")
150150
@render_widget
151151
def _():
152-
from bqplot import OrdinalScale, LinearScale, Bars, Lines, Axis, Figure
152+
from bqplot import Axis, Bars, Figure, LinearScale, Lines, OrdinalScale
153153

154154
size = 20
155155
x_data = np.arange(size)

examples/superzip/app.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
import os
2-
from typing import Tuple, List, Optional
2+
from typing import List, Optional, Tuple
33

4+
import ipyleaflet as leaf
5+
import ipywidgets
6+
import matplotlib as mpl
7+
import numpy as np
8+
import pandas as pd
9+
import plotly.figure_factory as ff
10+
import plotly.graph_objs as go
411
from htmltools import head_content
12+
from ipyleaflet import basemaps
13+
from matplotlib import cm
514
from shiny import *
615
from shiny.types import SilentException
16+
717
from shinywidgets import *
8-
import ipywidgets
9-
import ipyleaflet as leaf
10-
from ipyleaflet import basemaps
11-
import plotly.graph_objs as go
12-
import plotly.figure_factory as ff
13-
import pandas as pd
14-
import numpy as np
15-
import matplotlib as mpl
16-
from matplotlib import cm
1718

1819
color_palette = cm.get_cmap("viridis", 10)
1920

21+
2022
# TODO: how to handle nas (pd.isna)?
2123
def col_numeric(domain: Tuple[float, float], na_color: str = "#808080"):
2224
rescale = mpl.colors.Normalize(domain[0], domain[1])
@@ -108,7 +110,6 @@ def density_plot(
108110
title: Optional[str] = None,
109111
showlegend: bool = False,
110112
):
111-
112113
dat = [overall[var], in_bounds[var]]
113114
if var == "Population":
114115
dat = [np.log10(x) for x in dat]
@@ -142,7 +143,7 @@ def density_plot(
142143
),
143144
)
144145
# hovermode itsn't working properly when dynamically, absolutely positioned
145-
for i, trace in enumerate(fig.data):
146+
for _, trace in enumerate(fig.data):
146147
trace.update(hoverinfo="none")
147148

148149
if selected is not None:
@@ -180,7 +181,6 @@ def create_map(**kwargs):
180181

181182

182183
def server(input: Inputs, output: Outputs, session: Session):
183-
184184
# ------------------------------------------------------------------------
185185
# Main map logic
186186
# ------------------------------------------------------------------------

shinywidgets/_shinywidgets.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ def init_shiny_widget(w: Widget):
8585
# By the time we get here, the user has already had an opportunity to specify a model_id,
8686
# so it isn't yet populated, generate a random one so we can assign the same id to the comm
8787
if getattr(w, "_model_id", None) is None:
88-
setattr(w, "_model_id", uuid4().hex)
88+
w._model_id = uuid4().hex
8989

9090
# Initialize the comm...this will also send the initial state of the widget
9191
w.comm = ShinyComm(
92-
comm_id=getattr(w, "_model_id"),
92+
comm_id=w._model_id,
9393
comm_manager=COMM_MANAGER,
9494
target_name="jupyter.widgets",
9595
data={"state": state, "buffer_paths": buffer_paths},
@@ -239,8 +239,6 @@ def _as_widget(x: object) -> Widget:
239239

240240
elif pkg == "pydeck" and not isinstance(x, Widget):
241241
try:
242-
from pydeck.widget import DeckGLWidget
243-
244242
x = x.show()
245243
except Exception as e:
246244
raise RuntimeError(f"Failed to coerce {x} into a DeckGLWidget: {e}")

0 commit comments

Comments
 (0)