Skip to content
Open
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/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3731,7 +3731,7 @@ def _validate_item_type(self, val, item_type, is_instance):
if is_instance and not isinstance(v, item_type):
err_kind = "instances"
obj_display = lambda v: type(v)
elif not is_instance and (type(v) is not type or not issubclass(v, item_type)):
elif not is_instance and (not isinstance(v, type) or not issubclass(v, item_type)):
err_kind = "subclasses"
if err_kind:
raise TypeError(
Expand Down
8 changes: 8 additions & 0 deletions tests/testlist.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import abc
import re
import unittest

Expand All @@ -16,6 +17,7 @@ class Obj: pass
class SubObj1(Obj): pass
class SubObj2(Obj): pass
class DiffObj: pass
class SubObjMeta(Obj, metaclass=abc.ABCMeta): pass

class TestListParameters(unittest.TestCase):

Expand Down Expand Up @@ -109,6 +111,12 @@ def test_set_object_wrong_is_instance_type(self):
):
p.o = [DiffObj]

def test_set_object_subclass_custom_metaclass(self):
# A subclass defined with a custom metaclass should be accepted.
p = self.P()
p.o = [SubObjMeta]
assert p.o == [SubObjMeta]

def test_set_object_wrong_type(self):
p = self.P()
with pytest.raises(
Expand Down