Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError in python 3.13 #2065

Open
FFroehlich opened this issue Oct 22, 2024 · 7 comments
Open

TypeError in python 3.13 #2065

FFroehlich opened this issue Oct 22, 2024 · 7 comments

Comments

@FFroehlich
Copy link

The following import

from pint import UnitRegistry

fails under python 3.13 with error message

File ".../venv/lib/python3.13/site-packages/pint/__init__.py", line 18, in <module>
    from .delegates.formatter._format_helpers import formatter
  File ".../venv/lib/python3.13/site-packages/pint/delegates/__init__.py", line 12, in <module>
    from . import txt_defparser
  File ".../venv/lib/python3.13/site-packages/pint/delegates/txt_defparser/__init__.py", line 12, in <module>
    from .defparser import DefParser
  File ".../venv/lib/python3.13/site-packages/pint/delegates/txt_defparser/defparser.py", line 10, in <module>
    from . import block, common, context, defaults, group, plain, system
  File ".../venv/lib/python3.13/site-packages/pint/delegates/txt_defparser/common.py", line 23, in <module>
    @dataclass(frozen=True)
     ~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.13/3.13.0_1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/dataclasses.py", line 1295, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
                          frozen, match_args, kw_only, slots,
                          weakref_slot)
  File "/opt/homebrew/Cellar/python@3.13/3.13.0_1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/dataclasses.py", line 1043, in _process_class
    raise TypeError('cannot inherit frozen dataclass from a '
                    'non-frozen one')
TypeError: cannot inherit frozen dataclass from a non-frozen one
@FFroehlich FFroehlich changed the title Incompatibility with python 3.13 TypeError in python 3.13 Oct 22, 2024
@hgrecco
Copy link
Owner

hgrecco commented Oct 22, 2024

I will be relasing a new version tomorrow

@nhoover
Copy link

nhoover commented Oct 23, 2024

Great, thanks for fixing. I'm having the same issue.

ken-lauer added a commit to ken-lauer/distgen-feedstock that referenced this issue Oct 23, 2024
We can't even import `pint` in 3.13 due to bug in pint
hgrecco/pint#2065 - which means we can't build
with it here.
@amit-chen-ecoplant
Copy link

Is the new version out yet?
I'm still getting the same error
E TypeError: cannot inherit frozen dataclass from a non-frozen one

@nhoover
Copy link

nhoover commented Nov 1, 2024

@hgrecco any progress? Thanks

@jmtts
Copy link

jmtts commented Nov 7, 2024

We now also see this showing up on a fresh environment Python 3.12.5.

For anyone that needs a quick workaround: you can pin the flexparser to 0.3.1 (they released the 0.4 version about 9 hours ago).

Potentially linked to this issue: hgrecco/flexparser#12

$ pyenv virtualenv 3.12 pint-test
$ pyenv activate pint-test
$ python -m pip install pint
$ python -c "import pint"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/<path>/lib/python3.12/site-packages/pint/__init__.py", line 18, in <module>
    from .delegates.formatter._format_helpers import formatter
  File "/<path>/lib/python3.12/site-packages/pint/delegates/__init__.py", line 12, in <module>
    from . import txt_defparser
  File "/<path>/lib/python3.12/site-packages/pint/delegates/txt_defparser/__init__.py", line 12, in <module>
    from .defparser import DefParser
  File "/<path>/lib/python3.12/site-packages/pint/delegates/txt_defparser/defparser.py", line 10, in <module>
    from . import block, common, context, defaults, group, plain, system
  File "/<path>/lib/python3.12/site-packages/pint/delegates/txt_defparser/common.py", line 23, in <module>
    @dataclass(frozen=True)
     ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xxx/.pyenv/versions/3.12.5/lib/python3.12/dataclasses.py", line 1265, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xxx/.pyenv/versions/3.12.5/lib/python3.12/dataclasses.py", line 1029, in _process_class
    raise TypeError('cannot inherit frozen dataclass from a '
TypeError: cannot inherit frozen dataclass from a non-frozen one

@nhoover
Copy link

nhoover commented Nov 7, 2024

Using 0.24.4 it's now working for me with python 3.13.0

@jules-ch
Copy link
Collaborator

Is this issue resolved @hgrecco ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants