Skip to content

Commit c56b462

Browse files
committed
fmt
1 parent c5815a4 commit c56b462

File tree

2 files changed

+38
-7
lines changed

2 files changed

+38
-7
lines changed

pyteal/ast/abi/address.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
T = TypeVar("T", bound=BaseType)
1414
N = TypeVar("N", bound=int)
1515

16+
1617
class AddressTypeSpec(StaticArrayTypeSpec):
1718
def __init__(self) -> None:
1819
super().__init__(ByteTypeSpec(), ADDRESS_LENGTH)
@@ -40,16 +41,30 @@ def type_spec(self) -> AddressTypeSpec:
4041
def get(self) -> Expr:
4142
return self.stored_value.load()
4243

43-
def set(self, value: Union[Sequence[T], StaticArray[T, N], ComputedValue[StaticArray[T, N]], "Address", str, Expr]):
44-
44+
def set(
45+
self,
46+
value: Union[
47+
Sequence[T],
48+
StaticArray[T, N],
49+
ComputedValue[StaticArray[T, N]],
50+
"Address",
51+
str,
52+
Expr,
53+
],
54+
):
55+
4556
if isinstance(value, ComputedValue):
4657
if value.produced_type_spec() is not AddressTypeSpec():
47-
raise TealInputError(f"Got ComputedValue with type spec {value.produced_type_spec()}, expected AddressTypeSpec")
58+
raise TealInputError(
59+
f"Got ComputedValue with type spec {value.produced_type_spec()}, expected AddressTypeSpec"
60+
)
4861
return value.store_into(self)
4962

5063
if isinstance(value, BaseType):
5164
if value.type_spec() is not AddressTypeSpec():
52-
raise TealInputError(f"Got {value.__class__} with type spec {value.type_spec()}, expected AddressTypeSpec")
65+
raise TealInputError(
66+
f"Got {value.__class__} with type spec {value.type_spec()}, expected AddressTypeSpec"
67+
)
5368
return self.decode(self.encode())
5469

5570
if isinstance(value, str):

pyteal/ast/abi/string.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
def encoded_string(s: Expr):
2323
return Concat(Suffix(Itob(Len(s)), Int(6)), s)
2424

25+
2526
T = TypeVar("T", bound=BaseType)
2627

28+
2729
class StringTypeSpec(DynamicArrayTypeSpec):
2830
def __init__(self) -> None:
2931
super().__init__(ByteTypeSpec())
@@ -53,17 +55,31 @@ def get(self) -> Expr:
5355
self.stored_value.load(), Int(Uint16TypeSpec().byte_length_static())
5456
)
5557

56-
def set(self, value: Union[Sequence[T], DynamicArray[T], ComputedValue[DynamicArray[T]], "String", str, Expr]) -> Expr:
58+
def set(
59+
self,
60+
value: Union[
61+
Sequence[T],
62+
DynamicArray[T],
63+
ComputedValue[DynamicArray[T]],
64+
"String",
65+
str,
66+
Expr,
67+
],
68+
) -> Expr:
5769

5870
# Assume length prefixed
5971
if isinstance(value, ComputedValue):
6072
if value.produced_type_spec() is not StringTypeSpec():
61-
raise TealInputError(f"Got ComputedValue with type spec {value.produced_type_spec()}, expected StringTypeSpec")
73+
raise TealInputError(
74+
f"Got ComputedValue with type spec {value.produced_type_spec()}, expected StringTypeSpec"
75+
)
6276
return value.store_into(self)
6377

6478
if isinstance(value, BaseType):
6579
if value.type_spec() is not StringTypeSpec():
66-
raise TealInputError(f"Got {value.__class__} with type spec {value.type_spec()}, expected StringTypeSpec")
80+
raise TealInputError(
81+
f"Got {value.__class__} with type spec {value.type_spec()}, expected StringTypeSpec"
82+
)
6783
return value.decode(value.encode())
6884

6985
# Assume not length prefixed

0 commit comments

Comments
 (0)