Skip to content

Commit a9936c4

Browse files
committed
fmt
1 parent c5815a4 commit a9936c4

File tree

3 files changed

+39
-10
lines changed

3 files changed

+39
-10
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/array_dynamic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from pyteal.ast.expr import Expr
1111
from pyteal.ast.seq import Seq
1212

13-
from pyteal.ast.abi.type import ComputedValue, TypeSpec, BaseType
13+
from pyteal.ast.abi.type import ComputedValue, BaseType
1414
from pyteal.ast.abi.uint import Uint16
1515
from pyteal.ast.abi.array_base import ArrayTypeSpec, Array
1616

pyteal/ast/abi/string.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
from pyteal.ast.bytes import Bytes
1212
from pyteal.ast.unaryexpr import Itob, Len
1313
from pyteal.ast.substring import Suffix
14-
from pyteal.ast.int import Int
15-
from pyteal.ast.expr import Expr
1614
from pyteal.ast.naryexpr import Concat
1715

1816
from pyteal.types import TealType, require_type
@@ -22,8 +20,10 @@
2220
def encoded_string(s: Expr):
2321
return Concat(Suffix(Itob(Len(s)), Int(6)), s)
2422

23+
2524
T = TypeVar("T", bound=BaseType)
2625

26+
2727
class StringTypeSpec(DynamicArrayTypeSpec):
2828
def __init__(self) -> None:
2929
super().__init__(ByteTypeSpec())
@@ -53,17 +53,31 @@ def get(self) -> Expr:
5353
self.stored_value.load(), Int(Uint16TypeSpec().byte_length_static())
5454
)
5555

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

5868
# Assume length prefixed
5969
if isinstance(value, ComputedValue):
6070
if value.produced_type_spec() is not StringTypeSpec():
61-
raise TealInputError(f"Got ComputedValue with type spec {value.produced_type_spec()}, expected StringTypeSpec")
71+
raise TealInputError(
72+
f"Got ComputedValue with type spec {value.produced_type_spec()}, expected StringTypeSpec"
73+
)
6274
return value.store_into(self)
6375

6476
if isinstance(value, BaseType):
6577
if value.type_spec() is not StringTypeSpec():
66-
raise TealInputError(f"Got {value.__class__} with type spec {value.type_spec()}, expected StringTypeSpec")
78+
raise TealInputError(
79+
f"Got {value.__class__} with type spec {value.type_spec()}, expected StringTypeSpec"
80+
)
6781
return value.decode(value.encode())
6882

6983
# Assume not length prefixed

0 commit comments

Comments
 (0)