diff --git a/beaker/application.py b/beaker/application.py index f00a1813..556010b9 100644 --- a/beaker/application.py +++ b/beaker/application.py @@ -116,8 +116,7 @@ def __init__( *, descr: str | None = None, build_options: BuildOptions | None = None, - ): - ... + ): ... @overload def __init__( @@ -127,8 +126,7 @@ def __init__( state: TState, descr: str | None = None, build_options: BuildOptions | None = None, - ): - ... + ): ... def __init__( self, @@ -167,24 +165,25 @@ def state(self) -> TState: return self._state @overload - def precompiled(self, value: "Application", /) -> PrecompiledApplication: - ... + def precompiled(self, value: "Application", /) -> PrecompiledApplication: ... @overload - def precompiled(self, value: LogicSignature, /) -> PrecompiledLogicSignature: - ... + def precompiled(self, value: LogicSignature, /) -> PrecompiledLogicSignature: ... @overload def precompiled( self, value: LogicSignatureTemplate, / - ) -> PrecompiledLogicSignatureTemplate: - ... + ) -> PrecompiledLogicSignatureTemplate: ... def precompiled( self, value: "Application | LogicSignature | LogicSignatureTemplate", /, - ) -> PrecompiledApplication | PrecompiledLogicSignature | PrecompiledLogicSignatureTemplate: + ) -> ( + PrecompiledApplication + | PrecompiledLogicSignature + | PrecompiledLogicSignatureTemplate + ): """Precompile an Application or LogicSignature for use in the logic of the application.""" if value is self: @@ -292,9 +291,9 @@ def _register_bare_external( def deregister_bare_method( self, - action_name_or_reference: OnCompleteActionName - | Literal["clear_state"] - | SubroutineFnWrapper, + action_name_or_reference: ( + OnCompleteActionName | Literal["clear_state"] | SubroutineFnWrapper + ), /, ) -> None: if isinstance(action_name_or_reference, SubroutineFnWrapper): @@ -325,8 +324,7 @@ def external( self, fn: HandlerFunc, /, - ) -> ABIReturnSubroutine: - ... + ) -> ABIReturnSubroutine: ... # case 2: bare arg omitted @overload @@ -339,8 +337,7 @@ def external( authorize: AuthCallable | SubroutineFnWrapper | None = None, read_only: bool = False, override: bool | None = False, - ) -> ABIDecoratorFuncType: - ... + ) -> ABIDecoratorFuncType: ... # case 3: bare=False @overload @@ -354,8 +351,7 @@ def external( bare: Literal[False], read_only: bool = False, override: bool | None = False, - ) -> ABIDecoratorFuncType: - ... + ) -> ABIDecoratorFuncType: ... # case 4: bare=True @overload @@ -368,8 +364,7 @@ def external( authorize: AuthCallable | SubroutineFnWrapper | None = None, bare: Literal[True], override: bool | None = False, - ) -> BareDecoratorFuncType: - ... + ) -> BareDecoratorFuncType: ... # case 5: bare is a variable @overload @@ -383,8 +378,7 @@ def external( bare: bool, read_only: bool = False, override: bool | None = False, - ) -> DecoratorFuncType: - ... + ) -> DecoratorFuncType: ... def external( self, @@ -488,8 +482,7 @@ def create( self, fn: HandlerFunc, /, - ) -> ABIReturnSubroutine: - ... + ) -> ABIReturnSubroutine: ... # case 2: bare arg omitted @overload @@ -500,8 +493,7 @@ def create( name: str | None = None, authorize: AuthCallable | SubroutineFnWrapper | None = None, override: bool | None = False, - ) -> ABIDecoratorFuncType: - ... + ) -> ABIDecoratorFuncType: ... # case 3: bare=False @overload @@ -513,8 +505,7 @@ def create( authorize: AuthCallable | SubroutineFnWrapper | None = None, bare: Literal[False], override: bool | None = False, - ) -> ABIDecoratorFuncType: - ... + ) -> ABIDecoratorFuncType: ... # case 4: bare=True @overload @@ -526,8 +517,7 @@ def create( authorize: AuthCallable | SubroutineFnWrapper | None = None, bare: Literal[True], override: bool | None = False, - ) -> BareDecoratorFuncType: - ... + ) -> BareDecoratorFuncType: ... # case 5: bare is a variable @overload @@ -539,8 +529,7 @@ def create( authorize: AuthCallable | SubroutineFnWrapper | None = None, bare: bool, override: bool | None = False, - ) -> DecoratorFuncType: - ... + ) -> DecoratorFuncType: ... def create( self, @@ -568,8 +557,7 @@ def delete( self, fn: HandlerFunc, /, - ) -> ABIReturnSubroutine: - ... + ) -> ABIReturnSubroutine: ... # case 2: bare arg omitted @overload @@ -580,8 +568,7 @@ def delete( name: str | None = None, authorize: AuthCallable | SubroutineFnWrapper | None = None, override: bool | None = False, - ) -> ABIDecoratorFuncType: - ... + ) -> ABIDecoratorFuncType: ... # case 3: bare=False @overload @@ -593,8 +580,7 @@ def delete( authorize: AuthCallable | SubroutineFnWrapper | None = None, bare: Literal[False], override: bool | None = False, - ) -> ABIDecoratorFuncType: - ... + ) -> ABIDecoratorFuncType: ... # case 4: bare=True @overload @@ -606,8 +592,7 @@ def delete( authorize: AuthCallable | SubroutineFnWrapper | None = None, bare: Literal[True], override: bool | None = False, - ) -> BareDecoratorFuncType: - ... + ) -> BareDecoratorFuncType: ... # case 5: bare is a variable @overload @@ -619,8 +604,7 @@ def delete( authorize: AuthCallable | SubroutineFnWrapper | None = None, bare: bool, override: bool | None = False, - ) -> DecoratorFuncType: - ... + ) -> DecoratorFuncType: ... def delete( self, @@ -656,8 +640,7 @@ def update( self, fn: HandlerFunc, /, - ) -> ABIReturnSubroutine: - ... + ) -> ABIReturnSubroutine: ... # case 2: bare arg omitted @overload @@ -668,8 +651,7 @@ def update( name: str | None = None, authorize: AuthCallable | SubroutineFnWrapper | None = None, override: bool | None = False, - ) -> ABIDecoratorFuncType: - ... + ) -> ABIDecoratorFuncType: ... # case 3: bare=False @overload @@ -681,8 +663,7 @@ def update( authorize: AuthCallable | SubroutineFnWrapper | None = None, bare: Literal[False], override: bool | None = False, - ) -> ABIDecoratorFuncType: - ... + ) -> ABIDecoratorFuncType: ... # case 4: bare=True @overload @@ -694,8 +675,7 @@ def update( authorize: AuthCallable | SubroutineFnWrapper | None = None, bare: Literal[True], override: bool | None = False, - ) -> BareDecoratorFuncType: - ... + ) -> BareDecoratorFuncType: ... # case 5: bare is a variable @overload @@ -707,8 +687,7 @@ def update( authorize: AuthCallable | SubroutineFnWrapper | None = None, bare: bool, override: bool | None = False, - ) -> DecoratorFuncType: - ... + ) -> DecoratorFuncType: ... def update( self, @@ -743,8 +722,7 @@ def opt_in( self, fn: HandlerFunc, /, - ) -> ABIReturnSubroutine: - ... + ) -> ABIReturnSubroutine: ... # case 2: bare arg omitted @overload @@ -756,8 +734,7 @@ def opt_in( name: str | None = None, authorize: AuthCallable | SubroutineFnWrapper | None = None, override: bool | None = False, - ) -> ABIDecoratorFuncType: - ... + ) -> ABIDecoratorFuncType: ... # case 3: bare=False @overload @@ -770,8 +747,7 @@ def opt_in( authorize: AuthCallable | SubroutineFnWrapper | None = None, bare: Literal[False], override: bool | None = False, - ) -> ABIDecoratorFuncType: - ... + ) -> ABIDecoratorFuncType: ... # case 4: bare=True @overload @@ -784,8 +760,7 @@ def opt_in( authorize: AuthCallable | SubroutineFnWrapper | None = None, bare: Literal[True], override: bool | None = False, - ) -> BareDecoratorFuncType: - ... + ) -> BareDecoratorFuncType: ... # case 5: bare is a variable @overload @@ -798,8 +773,7 @@ def opt_in( authorize: AuthCallable | SubroutineFnWrapper | None = None, bare: bool = False, override: bool | None = False, - ) -> DecoratorFuncType: - ... + ) -> DecoratorFuncType: ... def opt_in( self, @@ -838,8 +812,7 @@ def close_out( self, fn: HandlerFunc, /, - ) -> ABIReturnSubroutine: - ... + ) -> ABIReturnSubroutine: ... # case 2: bare arg omitted @overload @@ -850,8 +823,7 @@ def close_out( name: str | None = None, authorize: AuthCallable | SubroutineFnWrapper | None = None, override: bool | None = False, - ) -> ABIDecoratorFuncType: - ... + ) -> ABIDecoratorFuncType: ... # case 3: bare=False @overload @@ -863,8 +835,7 @@ def close_out( authorize: AuthCallable | SubroutineFnWrapper | None = None, bare: Literal[False], override: bool | None = False, - ) -> ABIDecoratorFuncType: - ... + ) -> ABIDecoratorFuncType: ... # case 4: bare=True @overload @@ -876,8 +847,7 @@ def close_out( authorize: AuthCallable | SubroutineFnWrapper | None = None, bare: Literal[True], override: bool | None = False, - ) -> BareDecoratorFuncType: - ... + ) -> BareDecoratorFuncType: ... # case 5: bare is a variable @overload @@ -889,8 +859,7 @@ def close_out( authorize: AuthCallable | SubroutineFnWrapper | None = None, bare: bool, override: bool | None = False, - ) -> DecoratorFuncType: - ... + ) -> DecoratorFuncType: ... def close_out( self, @@ -925,8 +894,7 @@ def no_op( self, fn: HandlerFunc, /, - ) -> ABIReturnSubroutine: - ... + ) -> ABIReturnSubroutine: ... # case 2: bare arg omitted @overload @@ -940,8 +908,7 @@ def no_op( authorize: AuthCallable | SubroutineFnWrapper | None = None, read_only: bool = False, override: bool | None = False, - ) -> ABIDecoratorFuncType: - ... + ) -> ABIDecoratorFuncType: ... # case 3: bare=False @overload @@ -956,8 +923,7 @@ def no_op( bare: Literal[False], read_only: bool = False, override: bool | None = False, - ) -> ABIDecoratorFuncType: - ... + ) -> ABIDecoratorFuncType: ... # case 4: bare=True @overload @@ -971,8 +937,7 @@ def no_op( authorize: AuthCallable | SubroutineFnWrapper | None = None, bare: Literal[True], override: bool | None = False, - ) -> BareDecoratorFuncType: - ... + ) -> BareDecoratorFuncType: ... # case 5: bare is a variable @overload @@ -987,8 +952,7 @@ def no_op( bare: bool, read_only: bool = False, override: bool | None = False, - ) -> DecoratorFuncType: - ... + ) -> DecoratorFuncType: ... def no_op( self, @@ -1037,8 +1001,7 @@ def clear_state( self, fn: Callable[[], Expr], /, - ) -> SubroutineFnWrapper: - ... + ) -> SubroutineFnWrapper: ... @overload def clear_state( @@ -1047,8 +1010,7 @@ def clear_state( *, name: str | None = None, override: bool | None = False, - ) -> Callable[[Callable[[], Expr]], SubroutineFnWrapper]: - ... + ) -> Callable[[Callable[[], Expr]], SubroutineFnWrapper]: ... def clear_state( self, @@ -1344,24 +1306,27 @@ def this_app() -> Application[TState]: @overload -def precompiled(value: Application, /) -> PrecompiledApplication: - ... +def precompiled(value: Application, /) -> PrecompiledApplication: ... @overload -def precompiled(value: LogicSignature, /) -> PrecompiledLogicSignature: - ... +def precompiled(value: LogicSignature, /) -> PrecompiledLogicSignature: ... @overload -def precompiled(value: LogicSignatureTemplate, /) -> PrecompiledLogicSignatureTemplate: - ... +def precompiled( + value: LogicSignatureTemplate, / +) -> PrecompiledLogicSignatureTemplate: ... def precompiled( value: Application | LogicSignature | LogicSignatureTemplate, /, -) -> PrecompiledApplication | PrecompiledLogicSignature | PrecompiledLogicSignatureTemplate: +) -> ( + PrecompiledApplication + | PrecompiledLogicSignature + | PrecompiledLogicSignatureTemplate +): try: ctx_app: Application = this_app() except LookupError as err: diff --git a/beaker/consts.py b/beaker/consts.py index a6e27ce5..4974b4cd 100644 --- a/beaker/consts.py +++ b/beaker/consts.py @@ -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)) diff --git a/beaker/lib/storage/blob.py b/beaker/lib/storage/blob.py index a65f8bae..05c88026 100644 --- a/beaker/lib/storage/blob.py +++ b/beaker/lib/storage/blob.py @@ -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: ... diff --git a/beaker/precompile.py b/beaker/precompile.py index b4fc5f0b..30fcfbf7 100644 --- a/beaker/precompile.py +++ b/beaker/precompile.py @@ -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(), diff --git a/beaker/state/_abc.py b/beaker/state/_abc.py index 6fded27c..91003f10 100644 --- a/beaker/state/_abc.py +++ b/beaker/state/_abc.py @@ -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): diff --git a/beaker/state/primitive.py b/beaker/state/primitive.py index 50b11a3d..efb3c0d1 100644 --- a/beaker/state/primitive.py +++ b/beaker/state/primitive.py @@ -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""" diff --git a/beaker/state/reserved.py b/beaker/state/reserved.py index 44cdd058..8550fcf5 100644 --- a/beaker/state/reserved.py +++ b/beaker/state/reserved.py @@ -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 diff --git a/examples/account_storage/disk_hungry.py b/examples/account_storage/disk_hungry.py index cb6820b8..74d83b9f 100644 --- a/examples/account_storage/disk_hungry.py +++ b/examples/account_storage/disk_hungry.py @@ -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 diff --git a/examples/amm/amm_test.py b/examples/amm/amm_test.py index a640d2d3..a962fe06 100644 --- a/examples/amm/amm_test.py +++ b/examples/amm/amm_test.py @@ -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 ), diff --git a/examples/blueprint/app.py b/examples/blueprint/app.py index 0ca6b944..0bfc8dd0 100644 --- a/examples/blueprint/app.py +++ b/examples/blueprint/app.py @@ -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: diff --git a/examples/wormhole/wormhole.py b/examples/wormhole/wormhole.py index 0555ce29..f95da6b5 100644 --- a/examples/wormhole/wormhole.py +++ b/examples/wormhole/wormhole.py @@ -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( diff --git a/tests/helpers/unit_testing_helpers.py b/tests/helpers/unit_testing_helpers.py index 6539d5ad..a207ada4 100644 --- a/tests/helpers/unit_testing_helpers.py +++ b/tests/helpers/unit_testing_helpers.py @@ -1,4 +1,5 @@ """Module containing helper functions for testing PyTeal Utils.""" + from typing import Any import pyteal as pt @@ -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