Skip to content

Commit

Permalink
OpType(Enum) falls down on python 3.11.1 (#615)
Browse files Browse the repository at this point in the history
Fix by swapping in a `dataclass` where formerly a `NamedTuple` was used.
  • Loading branch information
tzaffi committed Dec 16, 2022
1 parent 12c1e5e commit 6c1adac
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
container: python:${{ matrix.python }}
strategy:
matrix:
python: ["3.10"]
python: ["3.10", "3.11"]
steps:
- run: python3 --version
- name: Check out code
Expand All @@ -29,7 +29,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python: [ "3.10" ]
python: ["3.10", "3.11"]
steps:
- name: Check out code
uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Introducing `AbstractVar` to abstract value access: store, load, and stack type. ([#584](https://github.com/algorand/pyteal/pull/584))
* NOTE: a backwards incompatable change was imposed in this PR: previous ABI value's public member `stored_value` with type `ScratchVar`, is now changed to protected member `_stored_value` with type `AbstractVar`.
* Starting with program version 9, when `scratch_slots` flag isn't provided to `OptimizeOptions`, default to optimizing. For versions 8 and earlier the default is and remains to _not_ optimize. ([#613](https://github.com/algorand/pyteal/pull/613))
* Replaced the usage of `typing.NamedTuple` with `dataclass` for `class OpType` in the **ir** package in order to avoid [a regression coming in Python 3.11.1](https://github.com/python/cpython/issues/100098) ([#615](https://github.com/algorand/pyteal/pull/615)).

# 0.20.1

Expand Down
9 changes: 7 additions & 2 deletions pyteal/ir/ops.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import NamedTuple
from dataclasses import dataclass
from enum import Enum, Flag, auto


Expand All @@ -11,7 +11,12 @@ class Mode(Flag):

Mode.__module__ = "pyteal"

OpType = NamedTuple("OpType", [("value", str), ("mode", Mode), ("min_version", int)])

@dataclass
class OpType:
value: str
mode: Mode
min_version: int


class Op(Enum):
Expand Down

0 comments on commit 6c1adac

Please sign in to comment.