Skip to content

♻️ split off source fields in NeedItem internal data #1491

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

Merged
merged 3 commits into from
Aug 13, 2025

Conversation

chrisjsewell
Copy link
Member

The source mapping data (docname, lineno, ...) is now stored in a separate field, which allows for more clarity over the source of the need, allows more source specific information to be stored, and has better type safety.

The users of these objects should see no change in its API

The source mapping data (docname, lineno, ...) is now stored in a separate field, which allows for more clarity over the source of the need, allows more source specific information to be stored, and has better type safety.

The users of these objects should see no change in its API
@chrisjsewell chrisjsewell requested a review from ubmarco August 13, 2025 14:43
Copy link

codecov bot commented Aug 13, 2025

Codecov Report

❌ Patch coverage is 96.77419% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.82%. Comparing base (4e10030) to head (8ed6201).
⚠️ Report is 149 commits behind head on master.

Files with missing lines Patch % Lines
sphinx_needs/need_item.py 95.45% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1491      +/-   ##
==========================================
+ Coverage   86.87%   88.82%   +1.94%     
==========================================
  Files          56       68      +12     
  Lines        6532     8639    +2107     
==========================================
+ Hits         5675     7674    +1999     
- Misses        857      965     +108     
Flag Coverage Δ
pytests 88.82% <96.77%> (+1.94%) ⬆️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines +414 to +415
need_type: str = "",
title: str = "",
Copy link
Member

Choose a reason for hiding this comment

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

Why would the need_type have a default? Isn't that required primary information when using the API?
For the title I remember it can potentially be generated from other sources.

Copy link
Member Author

@chrisjsewell chrisjsewell Aug 13, 2025

Choose a reason for hiding this comment

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

So this was only because the docname and lineno were already before these arguments, and I can't add defaults for these without adding defaults for the others. Otherwise I have to change the order and potentially break user code already using add_need as it currently is (if they are not using keyword arguments)

Copy link
Member

Choose a reason for hiding this comment

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

Ok got it. I see in generate_need (which is called by add_need), that the given need type is checked against the registered types and errors if it does not match, so I'm ok with that.

@chrisjsewell chrisjsewell requested a review from ubmarco August 13, 2025 18:19
Copy link
Member

@ubmarco ubmarco left a comment

Choose a reason for hiding this comment

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

I like the new need source implementation. It's the better structure to know where information comes from.

@chrisjsewell chrisjsewell merged commit f3a293c into master Aug 13, 2025
20 checks passed
@chrisjsewell chrisjsewell deleted the need_item_source branch August 13, 2025 20:22
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