Skip to content
Draft
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
2 changes: 1 addition & 1 deletion scripts/generate_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def output_doc_stubs(manager: mypy.build.BuildManager) -> None:

def output_combined_stub(stubs: "DocStub", output: Path) -> None:
# remove algopy imports that have been inlined
lines = ["# ruff: noqa: A001, E501, F403, PYI021, PYI034, W291, FBT001, PYI018"]
lines = ["# ruff: noqa: A001, E501, F403, PYI021, PYI034, W291, FBT001, PYI018, SLF001"]
rexported = list[str]()
for module, imports in stubs.collected_imports.items():
if imports.import_module:
Expand Down
19 changes: 10 additions & 9 deletions scripts/generate_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
pytypes.AssetType: pytypes.IntLiteralType,
pytypes.TransactionTypeType: None,
pytypes.OnCompleteActionType: None,
pytypes.BytesBackedType: None,
}
PYTYPE_REPR = {
value: f"pytypes.{key}"
Expand All @@ -54,18 +55,18 @@
StackType.address_or_index: [pytypes.AccountType, pytypes.UInt64Type],
StackType.application: [pytypes.ApplicationType, pytypes.UInt64Type],
StackType.asset: [pytypes.AssetType, pytypes.UInt64Type],
StackType.bytes: [pytypes.BytesType],
StackType.bytes_8: [pytypes.BytesType],
StackType.bytes_32: [pytypes.BytesType],
StackType.bytes_33: [pytypes.BytesType],
StackType.bytes_64: [pytypes.BytesType],
StackType.bytes_80: [pytypes.BytesType],
StackType.bytes_1232: [pytypes.BytesType],
StackType.bytes_1793: [pytypes.BytesType],
StackType.bytes: [pytypes.BytesType, pytypes.BytesBackedType],
StackType.bytes_8: [pytypes.BytesType, pytypes.BytesBackedType],
StackType.bytes_32: [pytypes.BytesType, pytypes.BytesBackedType],
StackType.bytes_33: [pytypes.BytesType, pytypes.BytesBackedType],
StackType.bytes_64: [pytypes.BytesType, pytypes.BytesBackedType],
StackType.bytes_80: [pytypes.BytesType, pytypes.BytesBackedType],
StackType.bytes_1232: [pytypes.BytesType, pytypes.BytesBackedType],
StackType.bytes_1793: [pytypes.BytesType, pytypes.BytesBackedType],
StackType.bool: [pytypes.BoolType, pytypes.UInt64Type],
StackType.bool_only: [pytypes.BoolType],
StackType.uint64: [pytypes.UInt64Type],
StackType.any: [pytypes.BytesType, pytypes.UInt64Type],
StackType.any: [pytypes.BytesType, pytypes.UInt64Type, pytypes.BytesBackedType],
StackType.box_name: [pytypes.BytesType], # TODO: should this be another type..?
StackType.address: [pytypes.AccountType],
StackType.bigint: [pytypes.BigUIntType],
Expand Down
1 change: 0 additions & 1 deletion src/puyapy/awst_build/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@
CLEAR_STATE_METHOD = "clear_state_program"
ALGOPY_OP_PREFIX = "algopy.op."
URANGE = "algopy._unsigned_builtins.urange"
CLS_ARC4_STRUCT_META = "algopy.arc4._StructMeta"
CLS_ARC4_ABI_CALL = "algopy.arc4.abi_call"
2 changes: 1 addition & 1 deletion src/puyapy/awst_build/eb/_bytes_backed.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
)


class BytesBackedTypeBuilder(TypeBuilder[_TPyType_co], abc.ABC):
class BytesConvertibleTypeBuilder(TypeBuilder[_TPyType_co], abc.ABC):
@typing.override
def member_access(self, name: str, location: SourceLocation) -> NodeBuilder:
typ = self.produces()
Expand Down
4 changes: 2 additions & 2 deletions src/puyapy/awst_build/eb/arc4/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from puyapy.awst_build.eb._base import FunctionBuilder
from puyapy.awst_build.eb._bytes_backed import (
BytesBackedInstanceExpressionBuilder,
BytesBackedTypeBuilder,
BytesConvertibleTypeBuilder,
)
from puyapy.awst_build.eb._utils import (
CopyBuilder,
Expand All @@ -46,7 +46,7 @@
)


class ARC4TypeBuilder(BytesBackedTypeBuilder[_TPyType_co], abc.ABC):
class ARC4TypeBuilder(BytesConvertibleTypeBuilder[_TPyType_co], abc.ABC):
def member_access(self, name: str, location: SourceLocation) -> NodeBuilder:
match name:
case "from_log":
Expand Down
4 changes: 2 additions & 2 deletions src/puyapy/awst_build/eb/arc4/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from puyapy import models
from puyapy.awst_build import intrinsic_factory, pytypes
from puyapy.awst_build.eb import _expect as expect
from puyapy.awst_build.eb._bytes_backed import BytesBackedTypeBuilder
from puyapy.awst_build.eb._bytes_backed import BytesConvertibleTypeBuilder
from puyapy.awst_build.eb._utils import compare_expr_bytes
from puyapy.awst_build.eb.arc4.static_array import StaticArrayExpressionBuilder
from puyapy.awst_build.eb.interface import (
Expand All @@ -31,7 +31,7 @@
logger = log.get_logger(__name__)


class AddressTypeBuilder(BytesBackedTypeBuilder[pytypes.ArrayType]):
class AddressTypeBuilder(BytesConvertibleTypeBuilder[pytypes.ArrayType]):
def __init__(self, location: SourceLocation):
super().__init__(pytypes.ARC4AddressType, location)

Expand Down
4 changes: 2 additions & 2 deletions src/puyapy/awst_build/eb/arc4/dynamic_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from puyapy.awst_build import pytypes
from puyapy.awst_build.eb import _expect as expect
from puyapy.awst_build.eb._base import FunctionBuilder, GenericTypeBuilder
from puyapy.awst_build.eb._bytes_backed import BytesBackedTypeBuilder
from puyapy.awst_build.eb._bytes_backed import BytesConvertibleTypeBuilder
from puyapy.awst_build.eb._utils import dummy_statement, dummy_value
from puyapy.awst_build.eb.arc4._base import _ARC4ArrayExpressionBuilder, arc4_bool_bytes
from puyapy.awst_build.eb.factories import builder_for_instance
Expand Down Expand Up @@ -51,7 +51,7 @@ def call(
)


class DynamicArrayTypeBuilder(BytesBackedTypeBuilder[pytypes.ArrayType]):
class DynamicArrayTypeBuilder(BytesConvertibleTypeBuilder[pytypes.ArrayType]):
def __init__(self, typ: pytypes.PyType, location: SourceLocation):
assert isinstance(typ, pytypes.ArrayType)
assert typ.generic == pytypes.GenericARC4DynamicArrayType
Expand Down
4 changes: 2 additions & 2 deletions src/puyapy/awst_build/eb/arc4/dynamic_bytes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from puyapy import models
from puyapy.awst_build import pytypes
from puyapy.awst_build.eb import _expect as expect
from puyapy.awst_build.eb._bytes_backed import BytesBackedTypeBuilder
from puyapy.awst_build.eb._bytes_backed import BytesConvertibleTypeBuilder
from puyapy.awst_build.eb._utils import dummy_value
from puyapy.awst_build.eb.arc4.dynamic_array import DynamicArrayExpressionBuilder
from puyapy.awst_build.eb.arc4.uint import UIntNTypeBuilder
Expand All @@ -25,7 +25,7 @@
logger = log.get_logger(__name__)


class DynamicBytesTypeBuilder(BytesBackedTypeBuilder[pytypes.ArrayType]):
class DynamicBytesTypeBuilder(BytesConvertibleTypeBuilder[pytypes.ArrayType]):
def __init__(self, location: SourceLocation):
super().__init__(pytypes.ARC4DynamicBytesType, location)

Expand Down
4 changes: 2 additions & 2 deletions src/puyapy/awst_build/eb/arc4/static_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from puyapy.awst_build import pytypes
from puyapy.awst_build.eb import _expect as expect
from puyapy.awst_build.eb._base import GenericTypeBuilder
from puyapy.awst_build.eb._bytes_backed import BytesBackedTypeBuilder
from puyapy.awst_build.eb._bytes_backed import BytesConvertibleTypeBuilder
from puyapy.awst_build.eb._utils import constant_bool_and_error
from puyapy.awst_build.eb.arc4._base import _ARC4ArrayExpressionBuilder
from puyapy.awst_build.eb.factories import builder_for_instance
Expand Down Expand Up @@ -55,7 +55,7 @@ def call(
)


class StaticArrayTypeBuilder(BytesBackedTypeBuilder[pytypes.ArrayType]):
class StaticArrayTypeBuilder(BytesConvertibleTypeBuilder[pytypes.ArrayType]):
def __init__(self, typ: pytypes.PyType, location: SourceLocation):
assert isinstance(typ, pytypes.ArrayType)
assert typ.generic == pytypes.GenericARC4StaticArrayType
Expand Down
4 changes: 2 additions & 2 deletions src/puyapy/awst_build/eb/arc4/struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from puyapy.awst_build.eb._base import FunctionBuilder, NotIterableInstanceExpressionBuilder
from puyapy.awst_build.eb._bytes_backed import (
BytesBackedInstanceExpressionBuilder,
BytesBackedTypeBuilder,
BytesConvertibleTypeBuilder,
)
from puyapy.awst_build.eb._utils import (
CopyBuilder,
Expand All @@ -28,7 +28,7 @@
logger = log.get_logger(__name__)


class ARC4StructTypeBuilder(BytesBackedTypeBuilder[pytypes.StructType]):
class ARC4StructTypeBuilder(BytesConvertibleTypeBuilder[pytypes.StructType]):
def __init__(self, typ: pytypes.PyType, location: SourceLocation):
assert isinstance(typ, pytypes.StructType)
assert pytypes.ARC4StructBaseType < typ
Expand Down
4 changes: 2 additions & 2 deletions src/puyapy/awst_build/eb/biguint.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from puyapy.awst_build.eb._base import NotIterableInstanceExpressionBuilder
from puyapy.awst_build.eb._bytes_backed import (
BytesBackedInstanceExpressionBuilder,
BytesBackedTypeBuilder,
BytesConvertibleTypeBuilder,
)
from puyapy.awst_build.eb._utils import dummy_statement
from puyapy.awst_build.eb.bool import BoolExpressionBuilder
Expand All @@ -38,7 +38,7 @@
logger = log.get_logger(__name__)


class BigUIntTypeBuilder(BytesBackedTypeBuilder):
class BigUIntTypeBuilder(BytesConvertibleTypeBuilder):
def __init__(self, location: SourceLocation):
super().__init__(pytypes.BigUIntType, location)

Expand Down
4 changes: 2 additions & 2 deletions src/puyapy/awst_build/eb/fixed_bytes.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from puyapy.awst_build.eb._base import FunctionBuilder, GenericTypeBuilder
from puyapy.awst_build.eb._bytes_backed import (
BytesBackedInstanceExpressionBuilder,
BytesBackedTypeBuilder,
BytesConvertibleTypeBuilder,
)
from puyapy.awst_build.eb._utils import (
compare_bytes,
Expand Down Expand Up @@ -111,7 +111,7 @@ def member_access(self, name: str, location: SourceLocation) -> NodeBuilder:
return super().member_access(name, location)


class FixedBytesTypeBuilder(BytesBackedTypeBuilder[pytypes.FixedBytesType]):
class FixedBytesTypeBuilder(BytesConvertibleTypeBuilder[pytypes.FixedBytesType]):
"""Handles parameterized FixedBytes types like FixedBytes[Literal[32]]."""

def __init__(self, typ: pytypes.PyType, location: SourceLocation):
Expand Down
4 changes: 2 additions & 2 deletions src/puyapy/awst_build/eb/reference_types/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from puyapy.awst_build import intrinsic_factory, pytypes
from puyapy.awst_build.eb import _expect as expect
from puyapy.awst_build.eb._base import FunctionBuilder
from puyapy.awst_build.eb._bytes_backed import BytesBackedTypeBuilder
from puyapy.awst_build.eb._bytes_backed import BytesConvertibleTypeBuilder
from puyapy.awst_build.eb._utils import (
cast_to_bytes,
compare_bytes,
Expand All @@ -42,7 +42,7 @@
logger = log.get_logger(__name__)


class AccountTypeBuilder(BytesBackedTypeBuilder):
class AccountTypeBuilder(BytesConvertibleTypeBuilder):
def __init__(self, location: SourceLocation):
super().__init__(pytypes.AccountType, location)

Expand Down
4 changes: 2 additions & 2 deletions src/puyapy/awst_build/eb/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from puyapy.awst_build.eb._base import FunctionBuilder
from puyapy.awst_build.eb._bytes_backed import (
BytesBackedInstanceExpressionBuilder,
BytesBackedTypeBuilder,
BytesConvertibleTypeBuilder,
)
from puyapy.awst_build.eb._utils import compare_bytes, dummy_statement, dummy_value
from puyapy.awst_build.eb.bool import BoolExpressionBuilder
Expand All @@ -43,7 +43,7 @@
logger = log.get_logger(__name__)


class StringTypeBuilder(BytesBackedTypeBuilder):
class StringTypeBuilder(BytesConvertibleTypeBuilder):
def __init__(self, location: SourceLocation):
super().__init__(pytypes.StringType, location)

Expand Down
Loading
Loading