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

fix(bc): only remove terms when asked #2060

Merged
merged 2 commits into from
Jun 11, 2024
Merged

Conversation

MartinBelthle
Copy link
Contributor

Rollback to old behavior (prior to #2052) + handle last term deletion

Copy link
Contributor

@laurent-laporte-pro laurent-laporte-pro left a comment

Choose a reason for hiding this comment

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

Good job! Some little improvements could be done.

terms_to_remove = {key for key in updated_cfg if ("%" in key or "." in key) and key not in updated_terms}
for term_id in terms_to_remove:
updated_cfg.pop(term_id, None)
updated_properties = self.dict(exclude={"command_context", "command_name", "version", "id"}, exclude_none=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

You should use:

excluded_fields = frozenset(ICommand.__fields__)
updated_properties = self.dict(exclude=excluded_fields, exclude_none=True)

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 needed to add the id which is not in the ICommand fields so the code goes like this :

excluded_fields = set(ICommand.__fields__) | {"id"}

@MartinBelthle MartinBelthle merged commit 3290eca into dev Jun 11, 2024
7 checks passed
@MartinBelthle MartinBelthle deleted the fix/do-not-remove-terms-in-bc branch June 11, 2024 08:09
@makdeuneuv makdeuneuv added this to the v2.17.2 milestone Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants