Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to latest mypy #147

Merged
merged 1 commit into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
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
133 changes: 69 additions & 64 deletions beaker/client/application_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def __init__(
client: AlgodClient,
app: Application,
app_id: int = 0,
signer: TransactionSigner = None,
sender: str = None,
suggested_params: transaction.SuggestedParams = None,
signer: TransactionSigner | None = None,
sender: str | None = None,
suggested_params: transaction.SuggestedParams | None = None,
):
self.client = client
self.app = app
Expand Down Expand Up @@ -93,12 +93,12 @@ def build(self) -> None:

def create(
self,
sender: str = None,
signer: TransactionSigner = None,
args: list[Any] = None,
suggested_params: transaction.SuggestedParams = None,
sender: str | None = None,
signer: TransactionSigner | None = None,
args: list[Any] | None = None,
suggested_params: transaction.SuggestedParams | None = None,
on_complete: transaction.OnComplete = transaction.OnComplete.NoOpOC,
extra_pages: int = None,
extra_pages: int | None = None,
**kwargs,
) -> tuple[int, str, str]:
"""Submits a signed ApplicationCallTransaction with application id == 0 and the schema and source from the Application passed"""
Expand Down Expand Up @@ -171,10 +171,10 @@ def create(

def update(
self,
sender: str = None,
signer: TransactionSigner = None,
args: list[Any] = None,
suggested_params: transaction.SuggestedParams = None,
sender: str | None = None,
signer: TransactionSigner | None = None,
args: list[Any] | None = None,
suggested_params: transaction.SuggestedParams | None = None,
**kwargs,
) -> str:

Expand Down Expand Up @@ -227,10 +227,10 @@ def update(

def opt_in(
self,
sender: str = None,
signer: TransactionSigner = None,
args: list[Any] = None,
suggested_params: transaction.SuggestedParams = None,
sender: str | None = None,
signer: TransactionSigner | None = None,
args: list[Any] | None = None,
suggested_params: transaction.SuggestedParams | None = None,
**kwargs,
) -> str:
"""Submits a signed ApplicationCallTransaction with OnComplete set to OptIn"""
Expand Down Expand Up @@ -278,10 +278,10 @@ def opt_in(

def close_out(
self,
sender: str = None,
signer: TransactionSigner = None,
args: list[Any] = None,
suggested_params: transaction.SuggestedParams = None,
sender: str | None = None,
signer: TransactionSigner | None = None,
args: list[Any] | None = None,
suggested_params: transaction.SuggestedParams | None = None,
**kwargs,
) -> str:
"""Submits a signed ApplicationCallTransaction with OnComplete set to CloseOut"""
Expand Down Expand Up @@ -329,10 +329,10 @@ def close_out(

def clear_state(
self,
sender: str = None,
signer: TransactionSigner = None,
args: list[Any] = None,
suggested_params: transaction.SuggestedParams = None,
sender: str | None = None,
signer: TransactionSigner | None = None,
args: list[Any] | None = None,
suggested_params: transaction.SuggestedParams | None = None,
**kwargs,
) -> str:

Expand Down Expand Up @@ -375,10 +375,10 @@ def clear_state(

def delete(
self,
sender: str = None,
signer: TransactionSigner = None,
args: list[Any] = None,
suggested_params: transaction.SuggestedParams = None,
sender: str | None = None,
signer: TransactionSigner | None = None,
args: list[Any] | None = None,
suggested_params: transaction.SuggestedParams | None = None,
**kwargs,
) -> str:
"""Submits a signed ApplicationCallTransaction with OnComplete set to DeleteApplication"""
Expand Down Expand Up @@ -425,7 +425,10 @@ def delete(
return delete_result.tx_ids[0]

def prepare(
self, signer: TransactionSigner = None, sender: str = None, **kwargs
self,
signer: TransactionSigner | None = None,
sender: str | None = None,
**kwargs,
) -> "ApplicationClient":

"""makes a copy of the current ApplicationClient and the fields passed"""
Expand All @@ -439,23 +442,23 @@ def prepare(
def call(
self,
method: abi.Method | HandlerFunc,
sender: str = None,
sender: str | None = None,
signer: TransactionSigner = None,
suggested_params: transaction.SuggestedParams = None,
suggested_params: transaction.SuggestedParams | None = None,
on_complete: transaction.OnComplete = transaction.OnComplete.NoOpOC,
local_schema: transaction.StateSchema = None,
global_schema: transaction.StateSchema = None,
approval_program: bytes = None,
clear_program: bytes = None,
extra_pages: int = None,
accounts: list[str] = None,
foreign_apps: list[int] = None,
foreign_assets: list[int] = None,
boxes: list[tuple[int, bytes]] = None,
note: bytes = None,
lease: bytes = None,
rekey_to: str = None,
atc: AtomicTransactionComposer = None,
local_schema: transaction.StateSchema | None = None,
global_schema: transaction.StateSchema | None = None,
approval_program: bytes | None = None,
clear_program: bytes | None = None,
extra_pages: int | None = None,
accounts: list[str] | None = None,
foreign_apps: list[int] | None = None,
foreign_assets: list[int] | None = None,
boxes: list[tuple[int, bytes]] | None = None,
note: bytes | None = None,
lease: bytes | None = None,
rekey_to: str | None = None,
atc: AtomicTransactionComposer | None = None,
**kwargs,
) -> ABIResult:

Expand Down Expand Up @@ -576,22 +579,22 @@ def add_method_call(
self,
atc: AtomicTransactionComposer,
method: abi.Method | HandlerFunc,
sender: str = None,
signer: TransactionSigner = None,
suggested_params: transaction.SuggestedParams = None,
sender: str | None = None,
signer: TransactionSigner | None = None,
suggested_params: transaction.SuggestedParams | None = None,
on_complete: transaction.OnComplete = transaction.OnComplete.NoOpOC,
local_schema: transaction.StateSchema = None,
global_schema: transaction.StateSchema = None,
approval_program: bytes = None,
clear_program: bytes = None,
extra_pages: int = None,
accounts: list[str] = None,
foreign_apps: list[int] = None,
foreign_assets: list[int] = None,
boxes: list[tuple[int, bytes]] = None,
note: bytes = None,
lease: bytes = None,
rekey_to: str = None,
local_schema: transaction.StateSchema | None = None,
global_schema: transaction.StateSchema | None = None,
approval_program: bytes | None = None,
clear_program: bytes | None = None,
extra_pages: int | None = None,
accounts: list[str] | None = None,
foreign_apps: list[int] | None = None,
foreign_assets: list[int] | None = None,
boxes: list[tuple[int, bytes]] | None = None,
note: bytes | None = None,
lease: bytes | None = None,
rekey_to: str | None = None,
**kwargs,
):

Expand Down Expand Up @@ -664,7 +667,7 @@ def add_transaction(
atc.add_transaction(TransactionWithSigner(txn=txn, signer=self.signer))
return atc

def fund(self, amt: int, addr: str = None) -> str:
def fund(self, amt: int, addr: str | None = None) -> str:
"""convenience method to pay the address passed, defaults to paying the app address for this client from the current signer"""
sender = self.get_sender()
signer = self.get_signer()
Expand Down Expand Up @@ -695,7 +698,7 @@ def get_application_state(self, raw=False) -> dict[bytes | str, bytes | str | in
)

def get_account_state(
self, account: str = None, raw: bool = False
self, account: str | None = None, raw: bool = False
) -> dict[str | bytes, bytes | str | int]:

"""gets the local state info for the app id set and the account specified"""
Expand Down Expand Up @@ -753,7 +756,7 @@ def method_hints(self, method_name: str) -> MethodHints:

def get_suggested_params(
self,
sp: transaction.SuggestedParams = None,
sp: transaction.SuggestedParams | None = None,
) -> transaction.SuggestedParams:

if sp is not None:
Expand All @@ -770,7 +773,7 @@ def wrap_approval_exception(self, e: Exception) -> Exception:

return LogicException(e, self.app.approval_program, self.approval_src_map)

def get_signer(self, signer: TransactionSigner = None) -> TransactionSigner:
def get_signer(self, signer: TransactionSigner | None = None) -> TransactionSigner:
if signer is not None:
return signer

Expand All @@ -779,7 +782,9 @@ def get_signer(self, signer: TransactionSigner = None) -> TransactionSigner:

raise Exception("No signer provided")

def get_sender(self, sender: str = None, signer: TransactionSigner = None) -> str:
def get_sender(
self, sender: str | None = None, signer: TransactionSigner | None = None
) -> str:
if sender is not None:
return sender

Expand Down
38 changes: 19 additions & 19 deletions beaker/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,12 +437,12 @@ def _impl(fn: HandlerFunc) -> HandlerFunc:


def external(
fn: HandlerFunc = None,
fn: HandlerFunc | None = None,
/,
*,
name: str = None,
authorize: SubroutineFnWrapper = None,
method_config: MethodConfig = None,
name: str | None = None,
authorize: SubroutineFnWrapper | None = None,
method_config: MethodConfig | None = None,
read_only: bool = False,
) -> HandlerFunc | Callable[..., HandlerFunc]:

Expand Down Expand Up @@ -489,12 +489,12 @@ def _impl(fn: HandlerFunc) -> HandlerFunc:


def bare_external(
no_op: CallConfig = None,
opt_in: CallConfig = None,
clear_state: CallConfig = None,
delete_application: CallConfig = None,
update_application: CallConfig = None,
close_out: CallConfig = None,
no_op: CallConfig | None = None,
opt_in: CallConfig | None = None,
clear_state: CallConfig | None = None,
delete_application: CallConfig | None = None,
update_application: CallConfig | None = None,
close_out: CallConfig | None = None,
) -> Callable[..., HandlerFunc]:
"""Add method to be handled by specific bare :code:`OnComplete` actions.

Expand Down Expand Up @@ -555,11 +555,11 @@ def is_bare(fn: HandlerFunc) -> bool:


def create(
fn: HandlerFunc = None,
fn: HandlerFunc | None = None,
/,
*,
authorize: SubroutineFnWrapper = None,
method_config: Optional[MethodConfig] = None,
authorize: SubroutineFnWrapper | None = None,
method_config: Optional[MethodConfig] | None = None,
) -> HandlerFunc | Callable[..., HandlerFunc]:
"""set method to be handled by an application call with its :code:`OnComplete`
set to :code:`NoOp` call and ApplicationId == 0
Expand Down Expand Up @@ -599,7 +599,7 @@ def _impl(fn: HandlerFunc) -> HandlerFunc:


def delete(
fn: HandlerFunc = None, /, *, authorize: SubroutineFnWrapper = None
fn: HandlerFunc | None = None, /, *, authorize: SubroutineFnWrapper | None = None
) -> HandlerFunc | Callable[..., HandlerFunc]:
"""set method to be handled by an application call with it's
:code:`OnComplete` set to :code:`DeleteApplication` call
Expand Down Expand Up @@ -633,7 +633,7 @@ def _impl(fn: HandlerFunc) -> HandlerFunc:


def update(
fn: HandlerFunc = None, /, *, authorize: SubroutineFnWrapper = None
fn: HandlerFunc | None = None, /, *, authorize: SubroutineFnWrapper | None = None
) -> HandlerFunc | Callable[..., HandlerFunc]:
"""set method to be handled by an application call with it's
:code:`OnComplete` set to :code:`UpdateApplication` call
Expand Down Expand Up @@ -667,7 +667,7 @@ def _impl(fn: HandlerFunc) -> HandlerFunc:


def opt_in(
fn: HandlerFunc = None, /, *, authorize: SubroutineFnWrapper = None
fn: HandlerFunc | None = None, /, *, authorize: SubroutineFnWrapper | None = None
) -> HandlerFunc | Callable[..., HandlerFunc]:
"""set method to be handled by an application call with it's
:code:`OnComplete` set to :code:`OptIn` call
Expand Down Expand Up @@ -700,7 +700,7 @@ def _impl(fn: HandlerFunc) -> HandlerFunc:


def clear_state(
fn: HandlerFunc = None, /, *, authorize: SubroutineFnWrapper = None
fn: HandlerFunc | None = None, /, *, authorize: SubroutineFnWrapper | None = None
) -> HandlerFunc | Callable[..., HandlerFunc]:
"""set method to be handled by an application call with it'ws
:code:`OnComplete` set to :code:`ClearState` call
Expand Down Expand Up @@ -734,7 +734,7 @@ def _impl(fn: HandlerFunc) -> HandlerFunc:


def close_out(
fn: HandlerFunc = None, /, *, authorize: SubroutineFnWrapper = None
fn: HandlerFunc | None = None, /, *, authorize: SubroutineFnWrapper | None = None
) -> HandlerFunc | Callable[..., HandlerFunc]:
"""set method to be handled by an application call with it's
:code:`OnComplete` set to :code:`CloseOut` call
Expand Down Expand Up @@ -768,7 +768,7 @@ def _impl(fn: HandlerFunc) -> HandlerFunc:


def no_op(
fn: HandlerFunc = None, /, *, authorize: SubroutineFnWrapper = None
fn: HandlerFunc | None = None, /, *, authorize: SubroutineFnWrapper | None = None
) -> HandlerFunc | Callable[..., HandlerFunc]:
"""set method to be handled by an application call with
it's :code:`OnComplete` set to :code:`NoOp` call
Expand Down
4 changes: 3 additions & 1 deletion beaker/lib/storage/_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
class List:
"""List stores a list of static types in a box, named as the class attribute unless an overriding name is provided"""

def __init__(self, value_type: type[abi.BaseType], elements: int, name: str = None):
def __init__(
self, value_type: type[abi.BaseType], elements: int, name: str | None = None
):
ts = abi.type_spec_from_annotation(value_type)

assert not ts.is_dynamic(), "Expected static type for value"
Expand Down
2 changes: 1 addition & 1 deletion beaker/logic_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class TemplateVariable(Expr):

"""

def __init__(self, stack_type: TealType, name: str = None):
def __init__(self, stack_type: TealType, name: str | None = None):
"""initialize the TemplateVariable and the scratch var it is stored in"""
assert stack_type in [TealType.bytes, TealType.uint64], "Must be bytes or uint"

Expand Down
Loading