Skip to content

Commit 3d91da4

Browse files
committed
fix: validate vyper types
1 parent 39456df commit 3d91da4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

sphinx_autodoc_vyper/parser.py

+8
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@
77
from typing import List, Optional
88

99

10+
VALID_VYPER_TYPES = {"address", "uint256", "int128", "bool", "bytes32", "string"}
11+
1012
@dataclass
1113
class Parameter:
1214
"""Function parameter representation."""
1315

1416
name: str
1517
type: str
1618

19+
def __post_init__(self) -> None:
20+
if self.type not in VALID_VYPER_TYPES:
21+
raise ValueError(f"{self} is not a valid Vyper type")
1722

1823
@dataclass
1924
class Function:
@@ -24,6 +29,9 @@ class Function:
2429
return_type: Optional[str]
2530
docstring: Optional[str]
2631

32+
def __post_init__(self) -> None:
33+
if self.return_type is not None and self.return_type not in VALID_VYPER_TYPES:
34+
raise ValueError(f"{self} does not return a valid Vyper type")
2735

2836
@dataclass
2937
class Contract:

0 commit comments

Comments
 (0)