-
Notifications
You must be signed in to change notification settings - Fork 81
✨ Add default and predicates keys to needs_fields and needs_extra_links, deprecates needs_global_options
#1612
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR deprecates needs_global_options in favor of adding default and predicates keys directly to needs_fields and needs_extra_links. This consolidation simplifies field schema configuration and enables future composability, such as per-need-type sub-schemas.
Key changes:
- Adds
defaultandpredicateskeys toneeds_fieldsandneeds_extra_linksconfiguration options - Deprecates
needs_global_optionswith a migration path - Updates documentation to reflect the new configuration approach
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_global_options.py | Removed (replaced by test_field_defaults.py) |
| tests/test_field_defaults.py | New comprehensive test file for field and link defaults |
| tests/doc_test/doc_field_defaults/index.rst | New test fixture for field defaults validation |
| tests/doc_test/doc_field_defaults/conf.py | Test configuration demonstrating new field/link default syntax |
| tests/snapshots/test_field_defaults.ambr | Snapshot data for field defaults tests |
| sphinx_needs/needs.py | Core logic changes to support defaults in fields/links and deprecate global_options |
| sphinx_needs/data.py | Updated docstring to remove reference to needs_global_options |
| sphinx_needs/config.py | Added default and predicates keys to LinkOptionsType and NeedFields types |
| docs/tutorial.rst | Updated to reference needs_extra_links instead of needs_global_options |
| docs/schema/index.rst | Updated to reference field/link defaults instead of needs_global_options |
| docs/dynamic_functions.rst | Removed needs_global_options from list of supported options |
| docs/directives/needextend.rst | Updated reference from needs_global_options to needs_fields |
| docs/directives/need.rst | Removed example using needs_global_options |
| docs/configuration.rst | Major restructure: moved needs_global_options to deprecated section and added default configuration to fields/links sections |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1612 +/- ##
==========================================
+ Coverage 86.87% 88.22% +1.34%
==========================================
Files 56 70 +14
Lines 6532 9907 +3375
==========================================
+ Hits 5675 8740 +3065
- Misses 857 1167 +310
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…tra_links`, deprecates `needs_global_options`,
7ab55af to
f54c3eb
Compare
| .. code-block:: python | ||
| needs_statuses = [ | ||
| dict(name="open", description="Nothing done yet"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are losing out on the description after the deprecation. Was this used for anything?
That could also be part of the schema description, if that's the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it wasn't used for anything in particular.
It's always nice to be able to document enum variants (as would be the rust terminology) but how can you do this in the schema? You could use oneOf + const, but that gets messy to "analyse"
{
"type": "string",
"oneOf": [
{
"const": "draft",
"description": "Work in progress; not yet reviewed"
},
{
"const": "approved",
"description": "Reviewed and approved for use"
},
{
"const": "rejected",
"description": "Reviewed and explicitly rejected"
}
]
}
This PR deprecates
needs_global_optionsin favor of addingdefaultandpredicateskeys directly toneeds_fieldsandneeds_extra_links.This consolidation follows on from #1611, to simplify field schema configuration and enables the possibility for future composability, such as per-need-type sub-schemas.
Key changes:
defaultandpredicateskeys toneeds_fieldsandneeds_extra_linksconfiguration optionsneeds_global_optionswith a migration pathAs per the new test, here is an example of moving from
needs_global_optionsto the new default configuration keys:OLD:
NEW: