-
Notifications
You must be signed in to change notification settings - Fork 9
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
Hashable Configurations #789
Conversation
If hashing is the only issue, it should be easier to simply add a custom |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## vara-dev #789 +/- ##
============================================
+ Coverage 67.43% 67.54% +0.11%
============================================
Files 322 322
Lines 24459 24590 +131
============================================
+ Hits 16493 16610 +117
- Misses 7966 7980 +14
☔ View full report in Codecov by Sentry. |
After discussing with @vulder I added a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
freezing impl looks fine to me, just suggested a bit of clean up
However, should we maybe add tests for the new FrozenConfiguration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
freezing impl looks fine to me, just suggested a bit of clean up
However, should we maybe add tests for the new FrozenConfiguration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
freezing impl looks fine to me, just suggested a bit of clean up
However, should we maybe add tests for the new FrozenConfiguration?
Looks like github has some issues currently... Somehow it registered by review twice |
…hem where possible
Our configurations are currently not hashable because they contain mutable objects, e.g
dict
orlist
. Therefore, they cannot be used as a key in adict
or as element in aset
which limits their usability.For example, in my other PR #718 I need a mapping from
Configuration -> Reports
. Currently my workaround was to rewrite my own immutable configuration class to make that work: https://github.com/se-sic/VaRA-Tool-Suite/pull/718/files#diff-46ee8773a540aedfd0d1cfbb2d2721a6191d64d3868c538d282c34f85a048492R50. But that basically duplicates functionality and it would be nice to reuse our existing configuration classes for that.However, a lot of our code relies on the mutability of configurations. Therefore, my proposal is to keep configurations mutable by default but make them immutable (freeze them) on demand. The immutables.map datatype provides these properties.
The committed code is a rough and far from perfect sketch how such a solution could look like. Apart from loosing the insertion order of configuration options it passes all tests. But I would like to collect some opinions first before pursuing this.