Skip to content

Commit

Permalink
Address linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Dec 27, 2023
1 parent a938929 commit 6d72a7c
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 37 deletions.
4 changes: 2 additions & 2 deletions panel/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,9 +911,9 @@ def _apply_signatures(self):
parameters = sig_params[:-1]

processed_kws, keyword_groups = set(), []
for cls in reversed(cls.mro()):
for scls in reversed(cls.mro()):
keyword_group = []
for (k, v) in sorted(cls.__dict__.items()):
for (k, v) in sorted(scls.__dict__.items()):
if (isinstance(v, param.Parameter) and k not in processed_kws
and not v.readonly):
keyword_group.append(k)
Expand Down
9 changes: 5 additions & 4 deletions panel/io/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -967,10 +967,11 @@ def curdoc(self) -> Document | None:
pyodide_session = self._is_pyodide and 'pyodide_kernel' not in sys.modules
if doc and (doc.session_context or pyodide_session):
return doc
finally:
curdoc = self._curdoc.get()
if curdoc:
return curdoc
except Exception:
pass
curdoc = self._curdoc.get()
if curdoc:
return curdoc

@curdoc.setter
def curdoc(self, doc: Document) -> None:
Expand Down
10 changes: 5 additions & 5 deletions panel/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,18 +578,18 @@ def _get_triggers(
def _get_specs(
self, link: 'Link', source: 'Reactive', target: 'JSLinkTarget'
) -> Sequence[Tuple['SourceModelSpec', 'TargetModelSpec', str | None]]:
for src_spec, code in link.code.items():
src_specs = src_spec.split('.')
if src_spec.startswith('event:'):
src_spec = (None, src_spec)
for spec in link.code:
src_specs = spec.split('.')
if spec.startswith('event:'):
src_spec = (None, spec)
elif len(src_specs) > 1:
src_spec = ('.'.join(src_specs[:-1]), src_specs[-1])
else:
src_prop = src_specs[0]
if isinstance(source, Reactive):
src_prop = source._rename.get(src_prop, src_prop)
src_spec = (None, src_prop)
return [(src_spec, (None, None), code)]
return [(src_spec, (None, None), link.code[spec])]



Expand Down
43 changes: 21 additions & 22 deletions panel/pane/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,47 +267,46 @@ def _update_object(
]
if indexes:
index = indexes[0]
new_model = (new_model,) + parent.children[index][1:]
parent.children[index] = new_model
else:
raise ValueError
new_model = (new_model,) + parent.children[index][1:]
elif isinstance(parent, _BkReactiveHTML):
for node, children in parent.children.items():
if old_model in children:
index = children.index(old_model)
new_models = list(children)
new_models[index] = new_model
parent.children[node] = new_models
break
elif isinstance(parent, _BkTabs):
index = [tab.child for tab in parent.tabs].index(old_model)
old_tab = parent.tabs[index]
props = dict(old_tab.properties_with_values(), child=new_model)
parent.tabs[index] = _BkTabPanel(**props)
else:
index = parent.children.index(old_model)
parent.children[index] = new_model
except ValueError:
self.param.warning(
f'{type(self).__name__} pane model {old_model!r} could not be '
f'replaced with new model {new_model!r}, ensure that the parent '
'is not modified at the same time the panel is being updated.'
)
else:
if isinstance(parent, _BkReactiveHTML):
parent.children[node] = new_models
elif isinstance(parent, _BkTabs):
old_tab = parent.tabs[index]
props = dict(old_tab.properties_with_values(), child=new_model)
parent.tabs[index] = _BkTabPanel(**props)
else:
parent.children[index] = new_model
layout_parent = self.layout._models.get(ref, [None])[0]
if parent is layout_parent:
parent.update(**self.layout._compute_sizing_mode(
parent.children,
dict(
sizing_mode=self.layout.sizing_mode,
styles=self.layout.styles,
width=self.layout.width,
min_width=self.layout.min_width,
margin=self.layout.margin
)
))
return

layout_parent = self.layout._models.get(ref, [None])[0]
if parent is layout_parent:
parent.update(**self.layout._compute_sizing_mode(
parent.children,
dict(
sizing_mode=self.layout.sizing_mode,
styles=self.layout.styles,
width=self.layout.width,
min_width=self.layout.min_width,
margin=self.layout.margin
)
))

from ..io import state
ref = root.ref['id']
Expand Down
2 changes: 0 additions & 2 deletions panel/tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ def app():
state.onload(cb2)
# Simulate rendering
def loaded():
state.curdoc
state._schedule_on_load(state.curdoc, None)
state.execute(loaded, schedule=True)
return 'App'
Expand All @@ -536,7 +535,6 @@ def app():
state.onload(cb2)
# Simulate rendering
def loaded():
state.curdoc
state._schedule_on_load(state.curdoc, None)
state.execute(loaded, schedule=True)
return 'App'
Expand Down
5 changes: 3 additions & 2 deletions panel/widgets/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,10 @@ def _sync_data(self, fileobj):
type(fileobj).__name__)

ext = filename.split('.')[-1]
for mtype, subtypes in self._mime_types.items():
stype = None
stype, mtype = None, None
for mime_type, subtypes in self._mime_types.items():
if ext in subtypes:
mtype = mime_type
stype = subtypes[ext]
break
if stype is None:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ ignore = [
"W605",
"E701", # Multiple statements on one line
"B006", # Do not use mutable data structures for argument defaults
"B019", # lru_cache and cache are used deliberately
]
select = [
"B",
Expand Down

0 comments on commit 6d72a7c

Please sign in to comment.