Skip to content

Commit

Permalink
Merge pull request #106 from PhilipVinc/pv/fix-parametric
Browse files Browse the repository at this point in the history
Fix #105
  • Loading branch information
PhilipVinc authored Sep 20, 2023
2 parents a7c8977 + 50ae604 commit 9ceec86
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion plum/parametric.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def class_new(cls, *args, **kw_args):
return original_class.__new__(cls)

cls.__new__ = class_new
original_class.__init_subclass__(**kw_args)
super(original_class, cls).__init_subclass__(**kw_args)

# Create parametric class.
parametric_class = meta(
Expand Down
22 changes: 22 additions & 0 deletions tests/test_parametric.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,3 +507,25 @@ class MockVal:
Val[1].__init__(MockVal())

assert repr(Val[1]()) == "plum.parametric.Val[1]()"


def test_init_subclass_correct_args():
# See issue https://github.com/beartype/plum/issues/105

from plum import parametric

register = set()

class Pytree:
def __init_subclass__(cls, **kwargs):
if cls in register:
raise ValueError("duplicate")
else:
register.add(cls)

@parametric
class Wrapper(Pytree):
pass

Wrapper[int]
assert Wrapper[int] in register

0 comments on commit 9ceec86

Please sign in to comment.