Skip to content

ref(grouping): Simplify handling of variant name and exception data #97458

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

lobsterkatie
Copy link
Member

During grouping, we pass data from one component strategy to another by storing it in the grouping context. In that context, two values - the variant name and a blob of exception data - are only sometimes defined. Until recently, the GroupingContext class supported key-lookup using subscript notation (context[some_key]) the same way a dictionary would, but lacked the safer .get() method. We therefore currently initialize both values to None, to prevent raising a KeyError if the values haven't been set.

Now that .get() has been implemented, though, we don't need to do that. This PR therefore switches the way we access them to use .get(), and removes the default initialization. In order to enforce when variant_name is or isn't expected to be defined, it also extends the practice already followed in some strategies of asserting on its existence (or lack thereof). This ensures that if we ever make changes to the grouping code, we'll know right away if our assumptions have been violated.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Aug 8, 2025
@lobsterkatie lobsterkatie marked this pull request as ready for review August 8, 2025 14:44
@lobsterkatie lobsterkatie requested a review from a team as a code owner August 8, 2025 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant