Skip to content

Conversation

@grahamalama
Copy link
Contributor

I noticed that we had a top-level actions key in project config. This seemed somewhat unnecessary since there aren't any other config objects besides actions. That meant that any time we wanted to access actions, we'd need to do actions_instance.actions.<whatever>.

This PR removes the top-level actions key in config and modifies the Actions Pydantic model to give it a __root__ property to contain the actions.

@grahamalama grahamalama requested a review from a team as a code owner July 8, 2022 16:24
@grahamalama grahamalama changed the title Remove top level config Remove top-level actions config key Jul 8, 2022
Copy link
Contributor

@bsieber-mozilla bsieber-mozilla left a comment

Choose a reason for hiding this comment

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

Minor suggestion; overall LGTM

@grahamalama grahamalama merged commit 839ec28 into mozilla:main Jul 11, 2022
@grahamalama grahamalama deleted the remove-top-level-config branch July 11, 2022 13:30
def all(self):
"""Return mapping of all actions"""
return self.actions
return self.__root__.get(tag.lower()) if tag else None
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we move this to __getitem__() ?

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 think they're different right?

__getitem__ is for actions['devtest'], which will throw a KeyError if the item is missing

vs actions.get("devtest") which will return None if the key doesn't exist.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, but one could rely on the other to match the actions[item.lower()] and actions[None] behaviour

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.

3 participants