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

feature/skip None values when merging #373

Merged
merged 2 commits into from
Jan 24, 2025

Conversation

cutoffthetop
Copy link
Contributor

PR Context

  • this broke the merging of optional fields, e.g. on ExtractedResources

Fixed

  • skip None values when merging extracted and rule items

@esinsj
Copy link
Contributor

esinsj commented Jan 24, 2025

I have a few questions to be able to review this PR:

  1. the Changelog says "skip None-values" but e.g. extending adds None-values and pruning removes them if they are given as a list (i.e. [None]). Is that relevant?
  2. For the pruning, a searched fieldname which should have a value removed, but which is non-existent in the dict, is not ignored but instead added to the dict as a new key. Is this the desired behavior? (e.g. see test_utils line 59ff)

@cutoffthetop
Copy link
Contributor Author

1. the Changelog says "skip None-values" but e.g. extending adds None-values and pruning removes them if they are given as a list (i.e. [None]). Is that relevant?

[None] is not (yet) relevant, because the input to the merging would be Extracted- and Rule-items - neither have fields that allow a None inside a list.

2. For the pruning, a searched fieldname which should have a value removed, but which is non-existent in the dict, is not ignored but instead added to the dict as a new key. Is this the desired behavior? (e.g. see test_utils line 59ff)

good observation, but this is also valid behavior for the merging use-case. because the resulting dict will be parsed into a AnyMergedItem (model_validate). and a key-value pair with an empty list as a value, is basically the same as not having the key.

@cutoffthetop cutoffthetop merged commit b9e8de1 into main Jan 24, 2025
4 checks passed
@cutoffthetop cutoffthetop deleted the feature/handle-null-values-while-merging branch January 24, 2025 12:08
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.

2 participants