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
tickets/DM-33977 Fixes for ConfigurableActionStructField #655
Conversation
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.
I think this needs a unit test. Otherwise looks good, but fix the "assignements" typo in one of the commit messages, too.
@@ -237,6 +247,21 @@ def __set__(self, instance: Config, | |||
if value is None or value == self.default: | |||
value = self.StructClass(instance, self, value, at=at, label=label) | |||
else: | |||
# An actual value is being assgigned check for what it is |
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.
# An actual value is being assgigned check for what it is | |
# An actual value is being assigned, check for what it is |
elif isinstance(value, (SimpleNamespace, Struct)): | ||
# If this is a a python analogous container, we need to make | ||
# a ConfigurableActionStruct initialized with this data | ||
value = self.StructClass(instance, self, vars(value), at=at, label=label) |
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.
Are you sure that the call to vars
doesn't return any "special" attributes for either SimpleNamespace
or Struct
? Seems like something worth adding a test for.
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.
I verified it though with a few tests in python manually, but I will add a unit test to guard against behavior changes (especially in Struct)
70dc373
to
af701d9
Compare
The ConfigurableActionStructField needs to be able to take appropriate assignements and either make a copy, or default construct an instance of ConfigurableActionStruct, otherwise the reference to the field object is lost.
If one adds attributes through a configurable action struct through the update interface it was possible to use a string that was not a valid python variable name, only to fail later when it was read or loaded through a config file. This validates that the strings are appropriate identifiers.
Add unit tests to test the behaviors when assigning to a ConfigurableActionStructField.
a7dbb50
to
a98ff70
Compare
This ticket fixes some assignment logic in ConfigurableActionStructField wherein a local copy of a ConfigurableActionStruct was not being made, leaving a dangling reference to a config object that goes out of scope.
This ticket also makes a change to stay in line with other pex_config fields wherein it takes other python classes that duck like a ConfigurableActionStructField as an argument in assigment.
Finally this ticket adds a verification that a string used in the dict update interface is a valid python identifier.