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

Convert ParsingError to dataclass(frozen=False) #12

Closed
LecrisUT opened this issue Oct 9, 2024 · 6 comments
Closed

Convert ParsingError to dataclass(frozen=False) #12

LecrisUT opened this issue Oct 9, 2024 · 6 comments

Comments

@LecrisUT
Copy link

LecrisUT commented Oct 9, 2024

This is a circular issue in combination with hgrecco/pint#2037

Either all of these exceptions are made frozen or unfrozen, we cannot mix each other. On pint side the issue is with dual inheritance with AttributeError which interferes. One option is to relax the frozenness on all pint errors, which includes flexparser as well, or we remove AttributeError inheritance. @hgrecco thoughts on which one would be preferred, neither of them is ideal unfortunately

@hgrecco
Copy link
Owner

hgrecco commented Nov 6, 2024

I just merge a PR to make exceptions non dataclasses. If there are no showstoppers, tomorrow I will try to use it in Pint.

@ollie-bell
Copy link

ollie-bell commented Nov 7, 2024

The release of 0.4 seems to be broken with Pint (currently only 0.24.3). Downgrading flexparser to 0.3.1 does not have this issue. Running Python 3.12.7.

    import pint
.venv/lib/python3.12/site-packages/pint/__init__.py:18: in <module>
    from .delegates.formatter._format_helpers import formatter
.venv/lib/python3.12/site-packages/pint/delegates/__init__.py:12: in <module>
    from . import txt_defparser
.venv/lib/python3.12/site-packages/pint/delegates/txt_defparser/__init__.py:12: in <module>
    from .defparser import DefParser
.venv/lib/python3.12/site-packages/pint/delegates/txt_defparser/defparser.py:10: in <module>
    from . import block, common, context, defaults, group, plain, system
.venv/lib/python3.12/site-packages/pint/delegates/txt_defparser/common.py:23: in <module>
    @dataclass(frozen=True)
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/dataclasses.py:1265: in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/dataclasses.py:1029: in _process_class
    raise TypeError('cannot inherit frozen dataclass from a '
E   TypeError: cannot inherit frozen dataclass from a non-frozen one

@LecrisUT
Copy link
Author

LecrisUT commented Nov 7, 2024

The release of 0.4 seems to be broken with Pint (currently only 0.24.3). Downgrading flexparser to 0.3.1 does not have this issue. Running Python 3.12.7.

This is expected, see the whole discussion thread in hgrecco/pint#2037. It is inevitable to break these two. Hopefully the pint update will come soon to unbreak things.

@ollie-bell
Copy link

Thanks - as a friendly suggestion to the maintainers of Pint and flexparser... I would recommend not doing a breaking release of flexparser whilst knowing that the latest released of Pint only specifies a lower bound dependency on flexparser.

@LecrisUT
Copy link
Author

LecrisUT commented Nov 7, 2024

Thanks - as a friendly suggestion to the maintainers of Pint and flexparser... I would recommend not doing a breaking release of flexparser whilst knowing that the latest released of Pint only specifies a lower bound dependency on flexparser.

Unfortunately the opposite (always higher-bounding dependencies) is also a maintenance burden often with no benefits. It's a balancing game and inevitably at any time one party will be affected either by python version incompatibility, dependency breakage, unblocking of higher bound (particularly when it's part of a long chain). My thought is to just hope for timely responses and help with the debugging.

@hgrecco
Copy link
Owner

hgrecco commented Nov 7, 2024

I am closing this issue as is fixed in Python 0.24.4 Please let me know if you encounter any problem.

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

3 participants