Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix misspelled parameter #575

Merged
merged 1 commit into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion param/parameterized.py
Original file line number Diff line number Diff line change
Expand Up @@ -2354,7 +2354,7 @@ def _spec_to_obj(self_, spec, dynamic=True, intermediate=True):
elif hasattr(src, attr):
info = MInfo(inst=inst, cls=cls, name=attr,
method=getattr(src, attr))
elif src.abstract:
elif getattr(src, "abstract", None):
return [], [] if intermediate == 'only' else [DInfo(spec=spec)]
else:
raise AttributeError("Attribute %r could not be resolved on %s."
Expand Down
25 changes: 25 additions & 0 deletions tests/API1/testparamdepends.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Unit test for param.depends.
"""

import pytest

import param

Expand Down Expand Up @@ -709,3 +710,27 @@ def function(value, c):
self.assertEqual(d, [4])
p.b = 3
self.assertEqual(d, [4, 5])


def test_misspelled_parameter_in_depends():
class Example(param.Parameterized):
xlim = param.Range((0, 10), bounds=(0, 100))

@param.depends("tlim") # <- Misspelled xlim
def test(self):
return True

example = Example()
with pytest.raises(AttributeError, match="Attribute 'tlim' could not be resolved on"):
# Simulating: pn.panel(example.test)
example.param.method_dependencies(example.test.__name__)


def test_misspelled_parameter_in_depends_watch():
with pytest.raises(AttributeError, match="Attribute 'tlim' could not be resolved on"):
class Example(param.Parameterized):
xlim = param.Range((0, 10), bounds=(0, 100))

@param.depends("tlim", watch=True) # <- Misspelled xlim
def test(self):
return True