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

🔧 Centralise need parts creation and strongly type needs #1129

Merged
merged 2 commits into from
Feb 28, 2024

Conversation

chrisjsewell
Copy link
Member

@chrisjsewell chrisjsewell commented Feb 25, 2024

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 the parts dict, since this is handled in iter_need_parts,
plus it removes the document key, since this appears to be an erroneous duplication of the needs docname field (the part is always in the same document as the parent need)

Since the NeedsPartsInfoType is now identical to NeedsInfoType 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.

Copy link

codecov bot commented Feb 25, 2024

Codecov Report

Attention: Patch coverage is 97.46835% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 85.92%. Comparing base (166a0e3) to head (a463e51).

Files Patch % Lines
sphinx_needs/api/need.py 66.66% 1 Missing ⚠️
sphinx_needs/data.py 98.24% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1129      +/-   ##
==========================================
- Coverage   85.94%   85.92%   -0.02%     
==========================================
  Files          56       56              
  Lines        6537     6531       -6     
==========================================
- Hits         5618     5612       -6     
  Misses        919      919              
Flag Coverage Δ
pytests 85.92% <97.46%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@danwos danwos left a comment

Choose a reason for hiding this comment

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

The for the cleanup.
Looks all good :) 👍

@chrisjsewell chrisjsewell merged commit 3343ea0 into master Feb 28, 2024
18 checks passed
@chrisjsewell chrisjsewell deleted the part-document-to-docname branch February 28, 2024 10:56
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.

None yet

2 participants