Skip to content

dataclasses: make sure inherited classes have correct frozenness - #566

Closed
matthiasdiener wants to merge 4 commits into
mainfrom
more-dc-frozenness
Closed

dataclasses: make sure inherited classes have correct frozenness#566
matthiasdiener wants to merge 4 commits into
mainfrom
more-dc-frozenness

Conversation

@matthiasdiener

@matthiasdiener matthiasdiener commented Dec 2, 2024

Copy link
Copy Markdown
Contributor

Without this, code would fail with optimizations enabled:

$ python -O ../grudge/examples/wave/wave-op-mpi.py
Traceback (most recent call last):
  File "/Users/mdiener/Work/enew/pytato/../grudge/examples/wave/wave-op-mpi.py", line 41, in <module>
    import grudge.op as op
  File "/Users/mdiener/Work/enew/grudge/grudge/op.py", line 109, in <module>
    from grudge.reductions import (
  File "/Users/mdiener/Work/enew/grudge/grudge/reductions.py", line 83, in <module>
    from grudge.array_context import MPIBasedArrayContext
  File "/Users/mdiener/Work/enew/grudge/grudge/array_context.py", line 41, in <module>
    from meshmode.array_context import (
  File "/Users/mdiener/Work/enew/meshmode/meshmode/array_context.py", line 1255, in <module>
    from pytato.analysis import PytatoKeyBuilder
  File "/Users/mdiener/Work/enew/pytato/pytato/__init__.py", line 50, in <module>
    import pytato.analysis as analysis
  File "/Users/mdiener/Work/enew/pytato/pytato/analysis/__init__.py", line 36, in <module>
    from pytato.array import (
  File "/Users/mdiener/Work/enew/pytato/pytato/array.py", line 913, in <module>
    @array_dataclass()
     ^^^^^^^^^^^^^^^^^
  File "/Users/mdiener/Work/enew/pytato/pytato/array.py", line 318, in map_cls
    dc_cls = dataclasses.dataclass(init=True, frozen=__debug__,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mdiener/Work/enew/miniforge3/envs/ceesd/lib/python3.12/dataclasses.py", line 1265, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mdiener/Work/enew/miniforge3/envs/ceesd/lib/python3.12/dataclasses.py", line 1024, in _process_class
    raise TypeError('cannot inherit non-frozen dataclass from a '
TypeError: cannot inherit non-frozen dataclass from a frozen one

Followup of #521.

@inducer

inducer commented Dec 2, 2024

Copy link
Copy Markdown
Owner

I'm generally OK with this, if the issues are resolvable.

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

Successfully merging this pull request may close these issues.

2 participants