Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The idea behind
FrozenClass
is to allow to add and change only certain variables in order to prevent bugs from typos.These are used in
status
objects, for instance. But we want to allow users to add status variables, without having a huge list of every variable anyone has ever used hardcoded in there.In this PR, I fix a truly horribly BS solution that I implemented when I didn't know class attributes. I wrote a very complicated function that loops through all objects and bypasses the
__set_attr__
functions by using__dict__
.The new solution uses a class attribute for
FrozenClass
and derived classes, which carries a list of the allowed variables. This can easily be appended, of course, but it cannot be confused with simple assignment.This should also give slightly better performance because the variables have to be added to the class only once, whereas they had to be added to each object before.
I did not do this too thoroughly. Basically, I refactored until the tests passed. I am sure there is some BS left in the convergence controllers related to this. But this I want to do when I have more time for refactoring. I just felt that the current version is too bad to leave as is.