nemocrys / pyelmer

A python interface to Elmer.
GNU General Public License v3.0
53 stars 15 forks source link

Problem with Python 3.11 #30

Closed Paul-Wray closed 1 month ago

Paul-Wray commented 1 year ago

Tried to setup and run examples. Exception with python 3.11.

File "/Users/pw/dml/elmertest.py", line 3, in from pyelmer import elmer File "/Users/pw/dml/lib/python3.11/site-packages/pyelmer/init.py", line 2, in from . import elmer, execute, post File "/Users/pw/dml/lib/python3.11/site-packages/pyelmer/post.py", line 17, in @dataclass ^^^^^^^^^ File "/Users/pw/.pyenv/versions/3.11.1/lib/python3.11/dataclasses.py", line 1220, in dataclass return wrap(cls) ^^^^^^^^^ File "/Users/pw/.pyenv/versions/3.11.1/lib/python3.11/dataclasses.py", line 1210, in wrap return _process_class(cls, init, repr, eq, order, unsafe_hash, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/pw/.pyenv/versions/3.11.1/lib/python3.11/dataclasses.py", line 958, in _process_class cls_fields.append(_get_field(cls, name, type, kw_only)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/pw/.pyenv/versions/3.11.1/lib/python3.11/dataclasses.py", line 815, in _get_field raise ValueError(f'mutable default {type(f.default)} for field ' ValueError: mutable default <class 'pyelmer.post.LinearIteration'> for field linear_iteration is not allowed: use default_factory (dml) pw@Pauls-iMac dml %

arvedes commented 1 year ago

I added default_factory, this should fix it. #7825b23

I just released a new version, can you try if it works with Python 3.11?

tpgillam commented 1 month ago

FYI, we're currently using pyelmer 1.2.1 with python 3.11 without issue. (so hopefully this can be closed!)