From d0b27db3a817c18c40557deedd7ccbb61bc2da84 Mon Sep 17 00:00:00 2001 From: Altynbek Orumbayev Date: Thu, 27 Jun 2024 15:59:29 +0200 Subject: [PATCH 1/3] fix: patching algopy import syntax in hello world --- .../.algokit.toml | 2 +- .../smart_contracts/{{ contract_name }}/contract.py.j2 | 7 ++++--- .../smart_contracts/cool_contract/contract.py | 7 ++++--- .../smart_contracts/hello_world/contract.py | 7 ++++--- .../.algokit.toml | 2 +- .../smart_contracts/{{ contract_name }}/contract.py.j2 | 7 ++++--- .../smart_contracts/cool_contract/contract.py | 7 ++++--- .../smart_contracts/hello_world/contract.py | 7 ++++--- .../smart_contracts/{{ contract_name }}/contract.py.j2 | 8 +++++--- .../smart_contracts/cool_contract/contract.py | 8 +++++--- .../smart_contracts/hello_world/contract.py | 9 +++++---- .../smart_contracts/{{ contract_name }}/contract.py.j2 | 8 +++++--- .../smart_contracts/cool_contract/contract.py | 8 +++++--- .../smart_contracts/hello_world/contract.py | 9 +++++---- examples/production_python/.algokit.toml | 2 +- .../smart_contracts/hello_world/contract.py | 7 ++++--- .../smart_contracts/hello_world/contract.py | 7 ++++--- template_content/.algokit.toml.jinja | 2 +- .../contract.py.j2 | 7 ++++--- .../{{ contract_name }}/contract.py.jinja | 7 ++++--- 20 files changed, 74 insertions(+), 54 deletions(-) diff --git a/examples/generators/production_python_smart_contract_python/.algokit.toml b/examples/generators/production_python_smart_contract_python/.algokit.toml index 6ebb852..9afc114 100644 --- a/examples/generators/production_python_smart_contract_python/.algokit.toml +++ b/examples/generators/production_python_smart_contract_python/.algokit.toml @@ -33,7 +33,7 @@ audit = { commands = [ 'poetry run pip-audit -r requirements.txt', ], description = 'Audit with pip-audit' } lint = { commands = [ - 'poetry run black --check .', + 'poetry run black --check --diff .', 'poetry run ruff check .', 'poetry run mypy', ], description = 'Perform linting' } diff --git a/examples/generators/production_python_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 b/examples/generators/production_python_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 index 0fb0bc7..829e3a0 100644 --- a/examples/generators/production_python_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 +++ b/examples/generators/production_python_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 @@ -1,8 +1,9 @@ # pyright: reportMissingModuleSource=false -from algopy import ARC4Contract, arc4 +from algopy import ARC4Contract, String +from algopy.arc4 import abimethod class {{ contract_name.split('_')|map('capitalize')|join }}(ARC4Contract): - @arc4.abimethod() - def hello(self, name: arc4.String) -> arc4.String: + @abimethod() + def hello(self, name: String) -> String: return "Hello, " + name diff --git a/examples/generators/production_python_smart_contract_python/smart_contracts/cool_contract/contract.py b/examples/generators/production_python_smart_contract_python/smart_contracts/cool_contract/contract.py index d4aca2c..271ad93 100644 --- a/examples/generators/production_python_smart_contract_python/smart_contracts/cool_contract/contract.py +++ b/examples/generators/production_python_smart_contract_python/smart_contracts/cool_contract/contract.py @@ -1,8 +1,9 @@ # pyright: reportMissingModuleSource=false -from algopy import ARC4Contract, arc4 +from algopy import ARC4Contract, String +from algopy.arc4 import abimethod class CoolContract(ARC4Contract): - @arc4.abimethod() - def hello(self, name: arc4.String) -> arc4.String: + @abimethod() + def hello(self, name: String) -> String: return "Hello, " + name diff --git a/examples/generators/production_python_smart_contract_python/smart_contracts/hello_world/contract.py b/examples/generators/production_python_smart_contract_python/smart_contracts/hello_world/contract.py index a0b333a..8a8d12b 100644 --- a/examples/generators/production_python_smart_contract_python/smart_contracts/hello_world/contract.py +++ b/examples/generators/production_python_smart_contract_python/smart_contracts/hello_world/contract.py @@ -1,7 +1,8 @@ -from algopy import ARC4Contract, arc4 +from algopy import ARC4Contract, String +from algopy.arc4 import abimethod class HelloWorld(ARC4Contract): - @arc4.abimethod() - def hello(self, name: arc4.String) -> arc4.String: + @abimethod() + def hello(self, name: String) -> String: return "Hello, " + name diff --git a/examples/generators/production_python_smart_contract_typescript/.algokit.toml b/examples/generators/production_python_smart_contract_typescript/.algokit.toml index 3cb1106..08ffaf7 100644 --- a/examples/generators/production_python_smart_contract_typescript/.algokit.toml +++ b/examples/generators/production_python_smart_contract_typescript/.algokit.toml @@ -33,7 +33,7 @@ audit = { commands = [ 'poetry run pip-audit -r requirements.txt', ], description = 'Audit with pip-audit' } lint = { commands = [ - 'poetry run black --check .', + 'poetry run black --check --diff .', 'poetry run ruff check .', 'poetry run mypy', ], description = 'Perform linting' } diff --git a/examples/generators/production_python_smart_contract_typescript/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 b/examples/generators/production_python_smart_contract_typescript/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 index 0fb0bc7..829e3a0 100644 --- a/examples/generators/production_python_smart_contract_typescript/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 +++ b/examples/generators/production_python_smart_contract_typescript/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 @@ -1,8 +1,9 @@ # pyright: reportMissingModuleSource=false -from algopy import ARC4Contract, arc4 +from algopy import ARC4Contract, String +from algopy.arc4 import abimethod class {{ contract_name.split('_')|map('capitalize')|join }}(ARC4Contract): - @arc4.abimethod() - def hello(self, name: arc4.String) -> arc4.String: + @abimethod() + def hello(self, name: String) -> String: return "Hello, " + name diff --git a/examples/generators/production_python_smart_contract_typescript/smart_contracts/cool_contract/contract.py b/examples/generators/production_python_smart_contract_typescript/smart_contracts/cool_contract/contract.py index d4aca2c..271ad93 100644 --- a/examples/generators/production_python_smart_contract_typescript/smart_contracts/cool_contract/contract.py +++ b/examples/generators/production_python_smart_contract_typescript/smart_contracts/cool_contract/contract.py @@ -1,8 +1,9 @@ # pyright: reportMissingModuleSource=false -from algopy import ARC4Contract, arc4 +from algopy import ARC4Contract, String +from algopy.arc4 import abimethod class CoolContract(ARC4Contract): - @arc4.abimethod() - def hello(self, name: arc4.String) -> arc4.String: + @abimethod() + def hello(self, name: String) -> String: return "Hello, " + name diff --git a/examples/generators/production_python_smart_contract_typescript/smart_contracts/hello_world/contract.py b/examples/generators/production_python_smart_contract_typescript/smart_contracts/hello_world/contract.py index a0b333a..8a8d12b 100644 --- a/examples/generators/production_python_smart_contract_typescript/smart_contracts/hello_world/contract.py +++ b/examples/generators/production_python_smart_contract_typescript/smart_contracts/hello_world/contract.py @@ -1,7 +1,8 @@ -from algopy import ARC4Contract, arc4 +from algopy import ARC4Contract, String +from algopy.arc4 import abimethod class HelloWorld(ARC4Contract): - @arc4.abimethod() - def hello(self, name: arc4.String) -> arc4.String: + @abimethod() + def hello(self, name: String) -> String: return "Hello, " + name diff --git a/examples/generators/starter_python_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 b/examples/generators/starter_python_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 index 0fb0bc7..e324d8d 100644 --- a/examples/generators/starter_python_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 +++ b/examples/generators/starter_python_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 @@ -1,8 +1,10 @@ # pyright: reportMissingModuleSource=false -from algopy import ARC4Contract, arc4 +from algopy import ARC4Contract, String +from algopy.arc4 import abimethod class {{ contract_name.split('_')|map('capitalize')|join }}(ARC4Contract): - @arc4.abimethod() - def hello(self, name: arc4.String) -> arc4.String: + @abimethod() + def hello(self, name: String) -> String: return "Hello, " + name + diff --git a/examples/generators/starter_python_smart_contract_python/smart_contracts/cool_contract/contract.py b/examples/generators/starter_python_smart_contract_python/smart_contracts/cool_contract/contract.py index d4aca2c..6daaedf 100644 --- a/examples/generators/starter_python_smart_contract_python/smart_contracts/cool_contract/contract.py +++ b/examples/generators/starter_python_smart_contract_python/smart_contracts/cool_contract/contract.py @@ -1,8 +1,10 @@ # pyright: reportMissingModuleSource=false -from algopy import ARC4Contract, arc4 +from algopy import ARC4Contract, String +from algopy.arc4 import abimethod class CoolContract(ARC4Contract): - @arc4.abimethod() - def hello(self, name: arc4.String) -> arc4.String: + @abimethod() + def hello(self, name: String) -> String: return "Hello, " + name + diff --git a/examples/generators/starter_python_smart_contract_python/smart_contracts/hello_world/contract.py b/examples/generators/starter_python_smart_contract_python/smart_contracts/hello_world/contract.py index a0b333a..a28dd20 100644 --- a/examples/generators/starter_python_smart_contract_python/smart_contracts/hello_world/contract.py +++ b/examples/generators/starter_python_smart_contract_python/smart_contracts/hello_world/contract.py @@ -1,7 +1,8 @@ -from algopy import ARC4Contract, arc4 - +from algopy import ARC4Contract, String +from algopy.arc4 import abimethod class HelloWorld(ARC4Contract): - @arc4.abimethod() - def hello(self, name: arc4.String) -> arc4.String: + @abimethod() + def hello(self, name: String) -> String: return "Hello, " + name + diff --git a/examples/generators/starter_python_smart_contract_typescript/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 b/examples/generators/starter_python_smart_contract_typescript/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 index 0fb0bc7..e324d8d 100644 --- a/examples/generators/starter_python_smart_contract_typescript/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 +++ b/examples/generators/starter_python_smart_contract_typescript/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 @@ -1,8 +1,10 @@ # pyright: reportMissingModuleSource=false -from algopy import ARC4Contract, arc4 +from algopy import ARC4Contract, String +from algopy.arc4 import abimethod class {{ contract_name.split('_')|map('capitalize')|join }}(ARC4Contract): - @arc4.abimethod() - def hello(self, name: arc4.String) -> arc4.String: + @abimethod() + def hello(self, name: String) -> String: return "Hello, " + name + diff --git a/examples/generators/starter_python_smart_contract_typescript/smart_contracts/cool_contract/contract.py b/examples/generators/starter_python_smart_contract_typescript/smart_contracts/cool_contract/contract.py index d4aca2c..6daaedf 100644 --- a/examples/generators/starter_python_smart_contract_typescript/smart_contracts/cool_contract/contract.py +++ b/examples/generators/starter_python_smart_contract_typescript/smart_contracts/cool_contract/contract.py @@ -1,8 +1,10 @@ # pyright: reportMissingModuleSource=false -from algopy import ARC4Contract, arc4 +from algopy import ARC4Contract, String +from algopy.arc4 import abimethod class CoolContract(ARC4Contract): - @arc4.abimethod() - def hello(self, name: arc4.String) -> arc4.String: + @abimethod() + def hello(self, name: String) -> String: return "Hello, " + name + diff --git a/examples/generators/starter_python_smart_contract_typescript/smart_contracts/hello_world/contract.py b/examples/generators/starter_python_smart_contract_typescript/smart_contracts/hello_world/contract.py index a0b333a..a28dd20 100644 --- a/examples/generators/starter_python_smart_contract_typescript/smart_contracts/hello_world/contract.py +++ b/examples/generators/starter_python_smart_contract_typescript/smart_contracts/hello_world/contract.py @@ -1,7 +1,8 @@ -from algopy import ARC4Contract, arc4 - +from algopy import ARC4Contract, String +from algopy.arc4 import abimethod class HelloWorld(ARC4Contract): - @arc4.abimethod() - def hello(self, name: arc4.String) -> arc4.String: + @abimethod() + def hello(self, name: String) -> String: return "Hello, " + name + diff --git a/examples/production_python/.algokit.toml b/examples/production_python/.algokit.toml index 58d90ea..8f08db0 100644 --- a/examples/production_python/.algokit.toml +++ b/examples/production_python/.algokit.toml @@ -33,7 +33,7 @@ audit = { commands = [ 'poetry run pip-audit -r requirements.txt', ], description = 'Audit with pip-audit' } lint = { commands = [ - 'poetry run black --check .', + 'poetry run black --check --diff .', 'poetry run ruff check .', 'poetry run mypy', ], description = 'Perform linting' } diff --git a/examples/production_python/smart_contracts/hello_world/contract.py b/examples/production_python/smart_contracts/hello_world/contract.py index a0b333a..8a8d12b 100644 --- a/examples/production_python/smart_contracts/hello_world/contract.py +++ b/examples/production_python/smart_contracts/hello_world/contract.py @@ -1,7 +1,8 @@ -from algopy import ARC4Contract, arc4 +from algopy import ARC4Contract, String +from algopy.arc4 import abimethod class HelloWorld(ARC4Contract): - @arc4.abimethod() - def hello(self, name: arc4.String) -> arc4.String: + @abimethod() + def hello(self, name: String) -> String: return "Hello, " + name diff --git a/examples/starter_python/smart_contracts/hello_world/contract.py b/examples/starter_python/smart_contracts/hello_world/contract.py index a0b333a..8a8d12b 100644 --- a/examples/starter_python/smart_contracts/hello_world/contract.py +++ b/examples/starter_python/smart_contracts/hello_world/contract.py @@ -1,7 +1,8 @@ -from algopy import ARC4Contract, arc4 +from algopy import ARC4Contract, String +from algopy.arc4 import abimethod class HelloWorld(ARC4Contract): - @arc4.abimethod() - def hello(self, name: arc4.String) -> arc4.String: + @abimethod() + def hello(self, name: String) -> String: return "Hello, " + name diff --git a/template_content/.algokit.toml.jinja b/template_content/.algokit.toml.jinja index 9ecaf47..7efab4b 100644 --- a/template_content/.algokit.toml.jinja +++ b/template_content/.algokit.toml.jinja @@ -48,7 +48,7 @@ audit = { commands = [ {%- endif %} lint = { commands = [ {%- if use_python_black %} - 'poetry run black --check .', + 'poetry run black --check --diff .', {%- endif %} {%- if python_linter == 'ruff' %} 'poetry run ruff check .', diff --git a/template_content/.algokit/generators/create_contract/smart_contracts/{% raw %}{{ contract_name }}{% endraw %}/contract.py.j2 b/template_content/.algokit/generators/create_contract/smart_contracts/{% raw %}{{ contract_name }}{% endraw %}/contract.py.j2 index 0fb0bc7..829e3a0 100644 --- a/template_content/.algokit/generators/create_contract/smart_contracts/{% raw %}{{ contract_name }}{% endraw %}/contract.py.j2 +++ b/template_content/.algokit/generators/create_contract/smart_contracts/{% raw %}{{ contract_name }}{% endraw %}/contract.py.j2 @@ -1,8 +1,9 @@ # pyright: reportMissingModuleSource=false -from algopy import ARC4Contract, arc4 +from algopy import ARC4Contract, String +from algopy.arc4 import abimethod class {{ contract_name.split('_')|map('capitalize')|join }}(ARC4Contract): - @arc4.abimethod() - def hello(self, name: arc4.String) -> arc4.String: + @abimethod() + def hello(self, name: String) -> String: return "Hello, " + name diff --git a/template_content/smart_contracts/{{ contract_name }}/contract.py.jinja b/template_content/smart_contracts/{{ contract_name }}/contract.py.jinja index 9828347..50ce4ca 100644 --- a/template_content/smart_contracts/{{ contract_name }}/contract.py.jinja +++ b/template_content/smart_contracts/{{ contract_name }}/contract.py.jinja @@ -1,7 +1,8 @@ -from algopy import ARC4Contract, arc4 +from algopy import ARC4Contract, String +from algopy.arc4 import abimethod class {{ contract_name.split('_')|map('capitalize')|join }}(ARC4Contract): - @arc4.abimethod() - def hello(self, name: arc4.String) -> arc4.String: + @abimethod() + def hello(self, name: String) -> String: return "Hello, " + name From 94c97f14e96da4fbf2578eb56defac1aa8e3012a Mon Sep 17 00:00:00 2001 From: Altynbek Orumbayev Date: Thu, 27 Jun 2024 16:03:27 +0200 Subject: [PATCH 2/3] chore: patch formatting --- .../smart_contracts/cool_contract/contract.py | 1 - .../smart_contracts/hello_world/contract.py | 2 +- .../smart_contracts/cool_contract/contract.py | 1 - .../smart_contracts/hello_world/contract.py | 2 +- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/generators/starter_python_smart_contract_python/smart_contracts/cool_contract/contract.py b/examples/generators/starter_python_smart_contract_python/smart_contracts/cool_contract/contract.py index 6daaedf..271ad93 100644 --- a/examples/generators/starter_python_smart_contract_python/smart_contracts/cool_contract/contract.py +++ b/examples/generators/starter_python_smart_contract_python/smart_contracts/cool_contract/contract.py @@ -7,4 +7,3 @@ class CoolContract(ARC4Contract): @abimethod() def hello(self, name: String) -> String: return "Hello, " + name - diff --git a/examples/generators/starter_python_smart_contract_python/smart_contracts/hello_world/contract.py b/examples/generators/starter_python_smart_contract_python/smart_contracts/hello_world/contract.py index a28dd20..8a8d12b 100644 --- a/examples/generators/starter_python_smart_contract_python/smart_contracts/hello_world/contract.py +++ b/examples/generators/starter_python_smart_contract_python/smart_contracts/hello_world/contract.py @@ -1,8 +1,8 @@ from algopy import ARC4Contract, String from algopy.arc4 import abimethod + class HelloWorld(ARC4Contract): @abimethod() def hello(self, name: String) -> String: return "Hello, " + name - diff --git a/examples/generators/starter_python_smart_contract_typescript/smart_contracts/cool_contract/contract.py b/examples/generators/starter_python_smart_contract_typescript/smart_contracts/cool_contract/contract.py index 6daaedf..271ad93 100644 --- a/examples/generators/starter_python_smart_contract_typescript/smart_contracts/cool_contract/contract.py +++ b/examples/generators/starter_python_smart_contract_typescript/smart_contracts/cool_contract/contract.py @@ -7,4 +7,3 @@ class CoolContract(ARC4Contract): @abimethod() def hello(self, name: String) -> String: return "Hello, " + name - diff --git a/examples/generators/starter_python_smart_contract_typescript/smart_contracts/hello_world/contract.py b/examples/generators/starter_python_smart_contract_typescript/smart_contracts/hello_world/contract.py index a28dd20..8a8d12b 100644 --- a/examples/generators/starter_python_smart_contract_typescript/smart_contracts/hello_world/contract.py +++ b/examples/generators/starter_python_smart_contract_typescript/smart_contracts/hello_world/contract.py @@ -1,8 +1,8 @@ from algopy import ARC4Contract, String from algopy.arc4 import abimethod + class HelloWorld(ARC4Contract): @abimethod() def hello(self, name: String) -> String: return "Hello, " + name - From 62fb51e588e98eda8bc16993bc67207778dbe6a6 Mon Sep 17 00:00:00 2001 From: Altynbek Orumbayev Date: Thu, 27 Jun 2024 16:07:55 +0200 Subject: [PATCH 3/3] chore: patch formatting --- .../smart_contracts/{{ contract_name }}/contract.py.j2 | 1 - .../smart_contracts/{{ contract_name }}/contract.py.j2 | 1 - 2 files changed, 2 deletions(-) diff --git a/examples/generators/starter_python_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 b/examples/generators/starter_python_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 index e324d8d..829e3a0 100644 --- a/examples/generators/starter_python_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 +++ b/examples/generators/starter_python_smart_contract_python/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 @@ -7,4 +7,3 @@ class {{ contract_name.split('_')|map('capitalize')|join }}(ARC4Contract): @abimethod() def hello(self, name: String) -> String: return "Hello, " + name - diff --git a/examples/generators/starter_python_smart_contract_typescript/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 b/examples/generators/starter_python_smart_contract_typescript/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 index e324d8d..829e3a0 100644 --- a/examples/generators/starter_python_smart_contract_typescript/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 +++ b/examples/generators/starter_python_smart_contract_typescript/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/contract.py.j2 @@ -7,4 +7,3 @@ class {{ contract_name.split('_')|map('capitalize')|join }}(ARC4Contract): @abimethod() def hello(self, name: String) -> String: return "Hello, " + name -