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

DM-17042: Improve parsing of config overrides #74

Merged
merged 1 commit into from Jan 8, 2019
Merged

Conversation

andy-slac
Copy link
Contributor

If string is passed as a field value but field has non-string type then
we convert string to Python object using ast.literal_eval. Unit tests
for various field types added as well.

try:
value = eval(value, {})
# use safer ast.literal_eval, it only supports literals
value = ast.literal_eval(value)
except Exception:
# Something weird happened here, try passing, and seeing if further
# code can handle this
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment block now makes no sense with the behavior below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I will rephrase that


# values of supported type
self.checkSingleFieldOverride(field, ["a", "b"], ["a", "b"])

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this implicitly support tuple if it was supplied? otherwise that might be a good test for parseable but invalid input

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tuple (or any iterable) is supported by ListField, I'll try to add something for parseable but invalid.

If string is passed as a field value but field has non-string type then
we convert string to Python object using `ast.literal_eval`. Unit tests
for various field types added as well.
@andy-slac andy-slac merged commit 3eae5ec into master Jan 8, 2019
@andy-slac andy-slac deleted the tickets/DM-17042 branch July 10, 2022 02:46
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.

None yet

2 participants