🔧 Centralise need parts creation and strongly type needs #1129
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Need "parts" (a.k.a. sub-needs) are expanded to full needs by copying the parent node then overding certain fields like the ID and content.
This PR replaces the duplicated logic by a single
iter_need_parts
function.It removes the
is_need
,is_part
keys from theparts
dict, since this is handled initer_need_parts
,plus it removes the
document
key, since this appears to be an erroneous duplication of the needsdocname
field (the part is always in the same document as the parent need)Since the
NeedsPartsInfoType
is now identical toNeedsInfoType
we remove it (these have to be identical, to allow filters to work for both)Lastly the https://docs.python.org/3/library/typing.html#typing.Required is added to core fields in
NeedsInfoType
,to allow for
add_need
to be properly typed checked, and so should ensure future code changes do not break the need schema.