Skip to content

Commit 74192f3

Browse files
authored
feat: error transformers feature parity with utils-ts (#186)
* feat: error transformers feature parity with utils-ts * chore: pip audit update for starlette * ci: run check docs on 3.12 * chore: remove logging * chore: removes unused import Removes an unused import from the transaction composer to address pr comment
1 parent e6c21b4 commit 74192f3

File tree

42 files changed

+1169
-69
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1169
-69
lines changed

.github/workflows/cd.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ jobs:
2626
name: Check Python
2727
uses: ./.github/workflows/check-python.yaml
2828

29+
ci-check-docs:
30+
name: Check Documentation
31+
uses: ./.github/workflows/check-docs.yaml
32+
2933
ci-build-python:
3034
name: Build Python
3135
uses: ./.github/workflows/build-python.yaml
32-
needs: ci-check-python
36+
needs: [ci-check-python, ci-check-docs]
3337

3438
release:
3539
name: Release Library

.github/workflows/check-docs.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Check Documentation
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
check-docs:
8+
runs-on: "ubuntu-latest"
9+
steps:
10+
- name: Checkout source code
11+
uses: actions/checkout@v4
12+
13+
- name: Set up Python 3.12
14+
uses: actions/setup-python@v5
15+
with:
16+
python-version: "3.12"
17+
18+
- name: Set up Poetry
19+
uses: ./.github/actions/setup-poetry
20+
21+
- name: Install dependencies
22+
run: poetry install --no-interaction --no-root
23+
24+
- name: Check docstrings are up to date
25+
run: poetry run poe docstrings-check
26+
27+
- name: Check docs are up to date
28+
run: |
29+
poetry run poe docs-md-only
30+
git diff --exit-code ':!docs/markdown/autoapi/index.md' ':!docs/markdown/autoapi/algokit_utils/applications/app_factory/index.md' docs

.github/workflows/check-python.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,3 @@ jobs:
4444
4545
- name: Check types with mypy
4646
run: poetry run mypy
47-
48-
- name: Check docstrings are up to date
49-
run: poetry run poe docstrings-check
50-
51-
- name: Check docs are up to date
52-
run: |
53-
poetry run poe docs-md-only
54-
git diff --exit-code ':!docs/markdown/autoapi/index.md' ':!docs/markdown/autoapi/algokit_utils/applications/app_factory/index.md' docs

.github/workflows/pr.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ jobs:
77
name: Check Python
88
uses: ./.github/workflows/check-python.yaml
99

10+
pr-check-docs:
11+
name: Check Documentation
12+
uses: ./.github/workflows/check-docs.yaml
13+
1014
pr-build:
1115
name: Build and Test Python
12-
needs: pr-check
16+
needs: [pr-check, pr-check-docs]
1317
uses: ./.github/workflows/build-python.yaml

docs/html/.buildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: 4f7050ca2baf67d0b4155492574876de
3+
config: 2184a2c4a238de4631c46327e4a9da60
44
tags: 645f666f9bcd5a90fca523b33c5a78b7

docs/html/.buildinfo.bak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: ff13c5f34153f29e8728e11dcd3c0679
3+
config: 4f7050ca2baf67d0b4155492574876de
44
tags: 645f666f9bcd5a90fca523b33c5a78b7

docs/html/_sources/autoapi/algokit_utils/algorand/index.rst.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,25 @@ Module Contents
104104

105105

106106

107+
.. py:method:: register_error_transformer(transformer: algokit_utils.transactions.transaction_composer.ErrorTransformer) -> typing_extensions.Self
108+
109+
Register a function that will be used to transform an error caught when simulating or executing
110+
composed transaction groups made from `new_group`
111+
112+
:param transformer: The error transformer function
113+
:return: The AlgorandClient so you can chain method calls
114+
115+
116+
117+
.. py:method:: unregister_error_transformer(transformer: algokit_utils.transactions.transaction_composer.ErrorTransformer) -> typing_extensions.Self
118+
119+
Unregister an error transformer function
120+
121+
:param transformer: The error transformer function to remove
122+
:return: The AlgorandClient so you can chain method calls
123+
124+
125+
107126
.. py:method:: new_group() -> algokit_utils.transactions.transaction_composer.TransactionComposer
108127
109128
Start a new `TransactionComposer` transaction group

docs/html/_sources/autoapi/algokit_utils/applications/enums/index.rst.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Classes
1717
Module Contents
1818
---------------
1919

20-
.. py:class:: OnSchemaBreak
20+
.. py:class:: OnSchemaBreak(*args, **kwds)
2121
2222
Bases: :py:obj:`enum.Enum`
2323

@@ -49,7 +49,7 @@ Module Contents
4949

5050

5151

52-
.. py:class:: OnUpdate
52+
.. py:class:: OnUpdate(*args, **kwds)
5353
5454
Bases: :py:obj:`enum.Enum`
5555

@@ -89,7 +89,7 @@ Module Contents
8989

9090

9191

92-
.. py:class:: OperationPerformed
92+
.. py:class:: OperationPerformed(*args, **kwds)
9393
9494
Bases: :py:obj:`enum.Enum`
9595

docs/html/_sources/autoapi/algokit_utils/protocols/typed_clients/index.rst.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ Module Contents
3030
...
3131

3232
Such classes are primarily used with static type checkers that recognize
33-
structural subtyping (static duck-typing), for example::
33+
structural subtyping (static duck-typing).
34+
35+
For example::
3436

3537
class C:
3638
def meth(self) -> int:
@@ -46,7 +48,7 @@ Module Contents
4648
only the presence of given attributes, ignoring their type signatures.
4749
Protocol classes can be generic, they are defined as::
4850

49-
class GenProto(Protocol[T]):
51+
class GenProto[T](Protocol):
5052
def meth(self) -> T:
5153
...
5254

@@ -75,7 +77,9 @@ Module Contents
7577
...
7678

7779
Such classes are primarily used with static type checkers that recognize
78-
structural subtyping (static duck-typing), for example::
80+
structural subtyping (static duck-typing).
81+
82+
For example::
7983

8084
class C:
8185
def meth(self) -> int:
@@ -91,7 +95,7 @@ Module Contents
9195
only the presence of given attributes, ignoring their type signatures.
9296
Protocol classes can be generic, they are defined as::
9397

94-
class GenProto(Protocol[T]):
98+
class GenProto[T](Protocol):
9599
def meth(self) -> T:
96100
...
97101

docs/html/_sources/autoapi/algokit_utils/transactions/transaction_composer/index.rst.txt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Attributes
99

1010
.. autoapisummary::
1111

12+
algokit_utils.transactions.transaction_composer.ErrorTransformer
1213
algokit_utils.transactions.transaction_composer.MethodCallParams
1314
algokit_utils.transactions.transaction_composer.AppMethodCallTransactionArgument
1415
algokit_utils.transactions.transaction_composer.TxnParams
@@ -58,6 +59,8 @@ Functions
5859
Module Contents
5960
---------------
6061

62+
.. py:data:: ErrorTransformer
63+
6164
.. py:class:: PaymentParams
6265
6366
Bases: :py:obj:`_CommonTxnParams`
@@ -1118,7 +1121,7 @@ Module Contents
11181121
:raises error: If there is an error from the Algorand node
11191122

11201123

1121-
.. py:class:: TransactionComposer(algod: algosdk.v2client.algod.AlgodClient, get_signer: collections.abc.Callable[[str], algosdk.atomic_transaction_composer.TransactionSigner], get_suggested_params: collections.abc.Callable[[], algosdk.transaction.SuggestedParams] | None = None, default_validity_window: int | None = None, app_manager: algokit_utils.applications.app_manager.AppManager | None = None)
1124+
.. py:class:: TransactionComposer(algod: algosdk.v2client.algod.AlgodClient, get_signer: collections.abc.Callable[[str], algosdk.atomic_transaction_composer.TransactionSigner], get_suggested_params: collections.abc.Callable[[], algosdk.transaction.SuggestedParams] | None = None, default_validity_window: int | None = None, app_manager: algokit_utils.applications.app_manager.AppManager | None = None, error_transformers: list[ErrorTransformer] | None = None)
11221125
11231126
A class for composing and managing Algorand transactions.
11241127

@@ -1131,6 +1134,16 @@ Module Contents
11311134
defaults to using algod.suggested_params()
11321135
:param default_validity_window: Optional default validity window for transactions in rounds, defaults to 10
11331136
:param app_manager: Optional AppManager instance for compiling TEAL programs, defaults to None
1137+
:param error_transformers: Optional list of error transformers to use when an error is caught in simulate or send
1138+
1139+
1140+
.. py:method:: register_error_transformer(transformer: ErrorTransformer) -> TransactionComposer
1141+
1142+
Register a function that will be used to transform an error caught when simulating or sending.
1143+
1144+
:param transformer: The error transformer function
1145+
:return: The composer so you can chain method calls
1146+
11341147

11351148

11361149
.. py:method:: add_transaction(transaction: algosdk.transaction.Transaction, signer: algosdk.atomic_transaction_composer.TransactionSigner | None = None) -> TransactionComposer
@@ -1555,7 +1568,7 @@ Module Contents
15551568

15561569
:param params: Parameters for the send operation
15571570
:return: The transaction send results
1558-
:raises Exception: If the transaction fails
1571+
:raises self._transform_error: If the transaction fails (may be transformed by error transformers)
15591572

15601573

15611574

0 commit comments

Comments
 (0)