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

👌 Improve parsing of need option lists with dynamic functions #1272

Merged
merged 2 commits into from
Sep 5, 2024

Conversation

chrisjsewell
Copy link
Member

For need directive options of the format e.g. :tags: a,[[func()]],b

Consolidate into single conversion function and add unit test

fixes #1271

Copy link

codecov bot commented Sep 3, 2024

Codecov Report

Attention: Patch coverage is 97.77778% with 1 line in your changes missing coverage. Please review.

Project coverage is 86.74%. Comparing base (4e10030) to head (698f37b).
Report is 32 commits behind head on master.

Files with missing lines Patch % Lines
sphinx_needs/api/need.py 97.77% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1272      +/-   ##
==========================================
- Coverage   86.87%   86.74%   -0.14%     
==========================================
  Files          56       60       +4     
  Lines        6532     6908     +376     
==========================================
+ Hits         5675     5992     +317     
- Misses        857      916      +59     
Flag Coverage Δ
pytests 86.74% <97.77%> (-0.14%) ⬇️

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.

@chrisjsewell chrisjsewell changed the title 👌 Improve parsing of need options containing dynamic functions 👌 Improve parsing of need option lists with dynamic functions Sep 3, 2024
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.

Thanks for the fix, looks good in general, just minor remarks.

sphinx_needs/api/need.py Show resolved Hide resolved
# Check if tag is in needs_tags. If not raise an error.
if needs_config.tags:
for tag in tags:
needs_tags = [tag["name"] for tag in needs_config.tags]
Copy link
Member

Choose a reason for hiding this comment

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

tag collides with outer tag variable (not a functional problem as this is like a lambda, however still fishy.
Another thing: needs_tags is generated for every tag in tags, however is never modified, so you can move it above the for loop.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed
(note I would also like to replace these exceptions with warnings, but that's another PR)

return []

if not isinstance(text, str):
assert isinstance(text, list) and all(
Copy link
Member

Choose a reason for hiding this comment

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

If this assertion raises it means a programming error in SN, right?
If not, just wondering, this will hard stop the build, right?

Copy link
Member Author

@chrisjsewell chrisjsewell Sep 5, 2024

Choose a reason for hiding this comment

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

yes it should be a programming error, so should be picked up in the test suite if failing

sphinx_needs/api/need.py Show resolved Hide resolved
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.

LGTM

@chrisjsewell chrisjsewell merged commit c862e9d into master Sep 5, 2024
17 checks passed
@chrisjsewell chrisjsewell deleted the split-list-with-dyn-funcs branch September 5, 2024 14:50
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.

Allow trailing comma for link options
2 participants