Skip to content

Commit a57093b

Browse files
committed
fix(mypy): fix type errs
1 parent 6e8077a commit a57093b

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

sphinx_autodoc_vyper/parser.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class DynArray:
4545
"""Dynamic length array representation."""
4646

4747
type: str
48-
max_length: int
48+
max_length: Union[int, Constant]
4949

5050
def __post_init__(self) -> None:
5151
if self.type not in VALID_VYPER_TYPES:
@@ -63,9 +63,9 @@ class Parameter:
6363
type: Type
6464

6565
def __post_init__(self) -> None:
66-
if self.type.startswith("DynArray"):
67-
assert self.type.endswith("]")
68-
type, max_length = self.type[:-1].split("[")[1].split(",")
66+
if self.type.startswith("DynArray"): # type: ignore [union-attr]
67+
assert self.type.endswith("]") # type: ignore [union-attr]
68+
type, max_length = self.type[:-1].split("[")[1].split(",") # type: ignore [index]
6969
try:
7070
self.type = DynArray(type, int(max_length))
7171
except ValueError:
@@ -95,8 +95,8 @@ class Function:
9595

9696
def __post_init__(self) -> None:
9797
if self.return_type is not None:
98-
if self.return_type.startswith("("):
99-
self.return_type = Tuple(self.return_type[1:-1].split(","))
98+
if self.return_type.startswith("("): # type: ignore [union-attr]
99+
self.return_type = Tuple(self.return_type[1:-1].split(",")) # type: ignore [index]
100100
elif self.return_type not in VALID_VYPER_TYPES:
101101
logger.warning(f"{self} does not return a valid Vyper type")
102102

@@ -217,9 +217,6 @@ def _parse_params(params_str: str) -> List[Parameter]:
217217
for param in re.finditer(param_pattern, params_str):
218218
name, type_str = param.group().split(":")
219219
type_str = type_str.strip()
220-
if type_str[1] == "(":
221-
typ = Tuple(type_str[1:-1].split(","))
222-
else:
223-
typ = type_str
220+
typ = Tuple(type_str[1:-1].split(",")) if type_str[1] == "(" else type_str
224221
params.append(Parameter(name=name.strip(), type=typ))
225222
return params

0 commit comments

Comments
 (0)