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

Freezing unfrozen dataclasses requires unfreezing them beforehand. #406

Open
SobhanMP opened this issue Jul 19, 2023 · 2 comments · May be fixed by #451
Open

Freezing unfrozen dataclasses requires unfreezing them beforehand. #406

SobhanMP opened this issue Jul 19, 2023 · 2 comments · May be fixed by #451

Comments

@SobhanMP
Copy link

import dataclasses
from etils import edc
@edc.dataclass(allow_unfrozen=True)
@dataclasses.dataclass(eq=True, kw_only=True)
class Conf:
    x: int = 3

a = Conf()
a.x = 2 # verify that a is not frozen
a.frozen() # complains that .frozen() can only be called after .unfrozen()

As the code above shows, allow_unfrozen seems to assume that the dataclass is frozen by default. I think that it should verify the assumption.

@Conchylicultor
Copy link
Member

Yes, this makes sense! Thank you for the feedback. Sending a fix now

@SobhanMP
Copy link
Author

Would have been nice to be able to freeze not frozen data classes too.

copybara-service bot pushed a commit that referenced this issue Oct 10, 2023
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 a pull request may close this issue.

2 participants