Skip to content

Commit

Permalink
run black
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-p committed Sep 24, 2024
1 parent 70a068b commit 6e199dc
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 128 deletions.
155 changes: 60 additions & 95 deletions beaker/application.py

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions beaker/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#: Used for runtime algo calculations `Txn.fee()==MilliAlgo`
MilliAlgo: Final[Int] = Int(milli_algo)


#: Used for shorthand for Int(10*algo) like Algos(10)
def Algos(v: int | float) -> Int: # noqa: N802
return Int(int(v * algo))
Expand Down
15 changes: 5 additions & 10 deletions beaker/lib/storage/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,16 @@ def _offset_for_idx(idx: Expr) -> Expr:
return idx % BLOB_PAGE_SIZE

@abstractmethod
def zero(self) -> Expr:
...
def zero(self) -> Expr: ...

@abstractmethod
def get_byte(self, idx: Int) -> Expr:
...
def get_byte(self, idx: Int) -> Expr: ...

@abstractmethod
def set_byte(self, idx: Int, byte: Expr) -> Expr:
...
def set_byte(self, idx: Int, byte: Expr) -> Expr: ...

@abstractmethod
def read(self, bstart: Expr, bstop: Expr) -> Expr:
...
def read(self, bstart: Expr, bstop: Expr) -> Expr: ...

@abstractmethod
def write(self, bstart: Expr, buff: Expr) -> Expr:
...
def write(self, bstart: Expr, buff: Expr) -> Expr: ...
8 changes: 5 additions & 3 deletions beaker/precompile.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,11 @@ def populate_template_expr(self, **kwargs: Expr) -> Expr:
arg = kwargs[name]
require_type(arg, TealType.bytes if tv.is_bytes else TealType.uint64)
populate_program += [
curr_val.store(Concat(EncodeUVarInt(Len(arg)), arg))
if tv.is_bytes
else curr_val.store(EncodeUVarInt(arg)),
(
curr_val.store(Concat(EncodeUVarInt(Len(arg)), arg))
if tv.is_bytes
else curr_val.store(EncodeUVarInt(arg))
),
buff.store(
Concat(
buff.load(),
Expand Down
15 changes: 5 additions & 10 deletions beaker/state/_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,23 @@ class AppSpecSchemaFragment(NamedTuple):

class StateStorage(ABC):
@abstractmethod
def app_spec_json(self) -> AppSpecSchemaFragment | None:
...
def app_spec_json(self) -> AppSpecSchemaFragment | None: ...

@abstractmethod
def num_keys(self) -> int:
...
def num_keys(self) -> int: ...

@abstractmethod
def value_type(self) -> Literal[TealType.bytes, TealType.uint64]:
...
def value_type(self) -> Literal[TealType.bytes, TealType.uint64]: ...


class GlobalStateStorage(StateStorage):
@abstractmethod
def initialize(self) -> Expr | None:
...
def initialize(self) -> Expr | None: ...


class LocalStateStorage(StateStorage):
@abstractmethod
def initialize(self, acct: Expr) -> Expr | None:
...
def initialize(self, acct: Expr) -> Expr | None: ...


# class BoxStorage(ABC):
Expand Down
3 changes: 1 addition & 2 deletions beaker/state/primitive.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ def __teal__(self, options: CompileOptions) -> tuple[TealBlock, TealSimpleBlock]
return self.get().__teal__(options)

@abstractmethod
def __str__(self) -> str:
...
def __str__(self) -> str: ...

def str_key(self) -> str:
"""returns the string held by the key Bytes object"""
Expand Down
3 changes: 1 addition & 2 deletions beaker/state/reserved.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ def __getitem__(self, key_seed: Expr | abi.BaseType) -> ST:
return self._get_state_for_key(key)

@abstractmethod
def _get_state_for_key(self, key: Expr) -> ST:
...
def _get_state_for_key(self, key: Expr) -> ST: ...

def num_keys(self) -> int:
return self.max_keys
Expand Down
1 change: 1 addition & 0 deletions examples/account_storage/disk_hungry.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
build_options=beaker.BuildOptions(avm_version=8),
)


# App that needs lots of storage so we use the local storage of
# unique lsig accounts that have been rekeyed to the app address.
# This allows us to use the local storage of the unique accounts
Expand Down
8 changes: 5 additions & 3 deletions examples/amm/amm_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,9 +686,11 @@ def valid_asset_xfer(key: str) -> XS:
wrong_receiver(mint(), key),
),
(
amm.Errors.AssetAIncorrect
if key == "a_xfer"
else amm.Errors.AssetBIncorrect,
(
amm.Errors.AssetAIncorrect
if key == "a_xfer"
else amm.Errors.AssetBIncorrect
),
override_axfer_asset(
mint(), key, b_asset if key == "a_xfer" else a_asset
),
Expand Down
1 change: 1 addition & 0 deletions examples/blueprint/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def add(a: abi.Uint64, b: abi.Uint64, *, output: abi.Uint64) -> Expr:

app = Application("BlueprintExampleNoArgs").apply(add_blueprint)


# A blueprint that adds a method named `addN` to the external
# methods of the Application passed
def add_n_blueprint(app: Application, n: int) -> None:
Expand Down
3 changes: 1 addition & 2 deletions examples/wormhole/wormhole.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ class WormholeStrategy(abc.ABC):
@abc.abstractmethod
def handle_transfer(
self, ctvaa: ContractTransferVAA, *, output: pt.abi.DynamicBytes
) -> pt.Expr:
...
) -> pt.Expr: ...


def wormhole_transfer(
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers/unit_testing_helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module containing helper functions for testing PyTeal Utils."""

from typing import Any

import pyteal as pt
Expand Down Expand Up @@ -26,7 +27,6 @@ def unit_test_app_blueprint(
/,
expr_to_test: pt.Expr | None = None,
) -> Application:

"""Base unit testable application.
There are 2 ways to use this class
Expand Down

0 comments on commit 6e199dc

Please sign in to comment.