Skip to content
Merged
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
30 changes: 16 additions & 14 deletions pyteal/ast/subroutine.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(
self.__name = self.implementation.__name__ if name_str is None else name_str

@staticmethod
def is_abi_annotation(obj: Any) -> bool:
def _is_abi_annotation(obj: Any) -> bool:
try:
abi.type_spec_from_annotation(obj)
return True
Expand All @@ -105,14 +105,16 @@ def _validate_parameter_type(
# * `invoke` type checks provided arguments against parameter types to catch mismatches.
return Expr
else:
if not isclass(ptype) and not SubroutineDefinition.is_abi_annotation(ptype):
if not isclass(ptype) and not SubroutineDefinition._is_abi_annotation(
ptype
):
raise TealInputError(
f"Function has parameter {parameter_name} of declared type {ptype} which is not a class"
)

if ptype in (Expr, ScratchVar):
return ptype
elif SubroutineDefinition.is_abi_annotation(ptype):
elif SubroutineDefinition._is_abi_annotation(ptype):
return abi.type_spec_from_annotation(ptype)
else:
raise TealInputError(
Expand Down Expand Up @@ -192,8 +194,8 @@ def _arg_types_and_by_refs(
)
abi_output_kwarg[name] = expected_arg_type
continue
else:
expected_arg_types.append(expected_arg_type)

expected_arg_types.append(expected_arg_type)

if expected_arg_type is ScratchVar:
by_ref_args.add(name)
Expand Down Expand Up @@ -299,15 +301,15 @@ class _OutputKwArgInfo:

@staticmethod
def from_dict(kwarg_info: dict[str, abi.TypeSpec]) -> Optional["_OutputKwArgInfo"]:
if kwarg_info is None or len(kwarg_info) == 0:
return None
elif len(kwarg_info) == 1:
key = list(kwarg_info.keys())[0]
return _OutputKwArgInfo(key, kwarg_info[key])
else:
raise TealInputError(
f"illegal conversion kwarg_info length {len(kwarg_info)}."
)
match list(kwarg_info.keys()):
case []:
return None
case [k]:
return _OutputKwArgInfo(k, kwarg_info[k])
case _:
raise TealInputError(
f"illegal conversion kwarg_info length {len(kwarg_info)}."
)


_OutputKwArgInfo.__module__ = "pyteal"
Expand Down