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

Enhancement: Upgrade black, mypy, and add type annotations to algod.py #442

Merged
merged 51 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
7bebd3f
Adding methods to use the simulate endpoint
barnjamin Dec 13, 2022
8ad7d0c
fix call to sim raw, add response format of msgpack
barnjamin Dec 14, 2022
601abe5
Merge branch 'develop' into simulate-endpoint
barnjamin Jan 20, 2023
a388e37
adding simulate to atc
barnjamin Jan 20, 2023
26e63e4
lint
barnjamin Jan 20, 2023
17a1b56
update names
barnjamin Feb 17, 2023
661e08c
passing msgpack in both response_format and format
barnjamin Feb 17, 2023
c6105af
tmp
barnjamin Feb 20, 2023
ffb8e64
Remove simulate response, dont bail on would_succeed false
barnjamin Feb 24, 2023
e9398f4
grab the right field out of the txn results
barnjamin Feb 24, 2023
26e7265
docstrings
barnjamin Feb 24, 2023
9dd2db6
provide more information since we get it back from simulate anyway
barnjamin Feb 25, 2023
c2f98f8
adding cucumber tests
barnjamin Feb 27, 2023
179c67d
try to make sandbox run against experimental-api branch
barnjamin Feb 27, 2023
7fbbb26
revert env var change
barnjamin Feb 27, 2023
882052e
remove extra kwarg
barnjamin Feb 27, 2023
5382250
add new test paths, remove json, add docstring
barnjamin Mar 2, 2023
5148785
Replace direct method access with method we've already got
barnjamin Mar 2, 2023
7fce7e0
latest black formatting (23.1.0)
Mar 2, 2023
35b92d1
Type Hints for algod.py
Mar 2, 2023
c8b303c
revert ATC simulate changes
Mar 2, 2023
ee7cc5b
handle circular import
Mar 2, 2023
56aaff3
Update algosdk/atomic_transaction_composer.py
tzaffi Mar 2, 2023
838e0e8
revert Simulate changes
Mar 2, 2023
d8d7673
Update tests/integration.tags
tzaffi Mar 2, 2023
500e8ed
more reverts
Mar 2, 2023
3e77dad
Merge branch 'develop' into algod-mypy
Mar 2, 2023
935ed1e
fix bad merge
Mar 2, 2023
b9a4d61
more hints when failing assertion
Mar 2, 2023
14152ec
oops - fix _specify_round_string
Mar 2, 2023
22cc731
reorder classes in atomic_transaction_composer.py
Mar 2, 2023
a04d9dc
sort imports
Mar 2, 2023
2c3162d
pin to sdk-testing branch
Mar 3, 2023
5c35e79
pin `SDK_TESTING_BRANCH="indexer-master"`
Mar 6, 2023
873437c
repin to SDK_TESTING_BRANCH=master since that branch was merged
Mar 6, 2023
e988d3a
revert to more readable side of demorgan
Mar 6, 2023
3e13b44
respond to Bob's CR question
Mar 6, 2023
e452759
Update algosdk/v2client/algod.py
tzaffi Mar 6, 2023
9025cef
restrict algod response types and assert appropriate usage
Mar 7, 2023
477d59a
lint
Mar 7, 2023
20327a3
revert per CR suggestions
Mar 7, 2023
7c535ce
revert
Mar 7, 2023
8862647
lint
Mar 7, 2023
2ea6e69
Update algosdk/v2client/algod.py
tzaffi Mar 7, 2023
98da646
Update algosdk/v2client/algod.py
tzaffi Mar 7, 2023
8757591
Merge branch 'develop' into algod-mypy
Mar 12, 2023
c8f0ac5
merge and tweak
Mar 12, 2023
354b796
complete typing
Mar 13, 2023
b2c88d5
simplify params type
Mar 13, 2023
546c3d1
tighten types
Mar 13, 2023
cbdf569
return right away
Mar 13, 2023
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
1 change: 1 addition & 0 deletions algosdk/abi/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from algosdk.abi.method import Method, MethodDict, get_method_by_name


# In Python 3.11+ the following classes should be combined using `NotRequired`
class InterfaceDict_Optional(TypedDict, total=False):
desc: str
Expand Down
1 change: 1 addition & 0 deletions algosdk/abi/method.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from algosdk import abi, constants, error


# In Python 3.11+ the following classes should be combined using `NotRequired`
class MethodDict_Optional(TypedDict, total=False):
desc: str
Expand Down
3 changes: 2 additions & 1 deletion algosdk/atomic_transaction_composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,8 @@ def execute(
tx_info=cast(Any, tx_info),
method=self.method_dict[i],
)
method_results.append(abi_result)

method_results.append(abi_result)
tzaffi marked this conversation as resolved.
Show resolved Hide resolved

return AtomicTransactionResponse(
confirmed_round=confirmed_round,
Expand Down
2 changes: 0 additions & 2 deletions algosdk/dryrun_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,9 @@ def trace(
disassembly: List[str],
spc: StackPrinterConfig,
) -> str:

# 16 for length of the header up to spaces
lines = [["pc#", "ln#", "source", "scratch", "stack"]]
for idx in range(len(dr_trace.trace)):

trace_line = dr_trace.trace[idx]

src = disassembly[trace_line.line]
Expand Down
4 changes: 2 additions & 2 deletions algosdk/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def __init__(self):


class OverspecifiedRoundError(Exception):
def __init__(self, contract_type):
def __init__(self):
Exception.__init__(
self,
"Two arguments were given for the round "
Expand All @@ -150,7 +150,7 @@ def __init__(self, contract_type):


class UnderspecifiedRoundError(Exception):
def __init__(self, contract_type):
def __init__(self):
Exception.__init__(self, "Please specify a round number")


Expand Down
1 change: 0 additions & 1 deletion algosdk/source_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class SourceMap:
"""

def __init__(self, source_map: Dict[str, Any]):

self.version: int = source_map["version"]

if self.version != 3:
Expand Down
2 changes: 0 additions & 2 deletions algosdk/testing/dryrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ def assertGlobalStateContains(
and txn_res["global-delta"] is not None
and len(txn_res["global-delta"]) > 0
):

found = Helper.find_delta_value(
txn_res["global-delta"], delta_value
)
Expand Down Expand Up @@ -363,7 +362,6 @@ def assertLocalStateContains(
and txn_res["local-deltas"] is not None
and len(txn_res["local-deltas"]) > 0
):

for local_delta in txn_res["local-deltas"]:
addr_found = False
if local_delta["address"] == addr:
Expand Down
7 changes: 7 additions & 0 deletions algosdk/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -3356,3 +3356,10 @@ def decode_programs(app):
app["params"]["clear-state-program"]
)
return app


GenericSignedTransaction = Union[
SignedTransaction,
LogicSigTransaction,
MultisigTransaction,
]
Loading