Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
Add private field to access declared types
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienLavoie committed Feb 15, 2020
1 parent 0c33d30 commit a0a9315
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions adt/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ def adt(cls):
cls._Key = Enum( # type: ignore
'_Key', list(caseConstructors.keys()))

values = list(caseConstructors.values())
types = []
for i in range(len(caseConstructors.values())):
try:
types.append(values[i]._argType)
except AttributeError:
try:
types.append(values[i]._types)
except AttributeError:
types.append(None)
cls._types = types

_installInit(cls)
_installRepr(cls)
_installStr(cls)
Expand Down

0 comments on commit a0a9315

Please sign in to comment.