👌 Expose parse_dynamic_functions in field/link configuration#1660
Merged
chrisjsewell merged 1 commit intomasterfrom Feb 19, 2026
Merged
👌 Expose parse_dynamic_functions in field/link configuration#1660chrisjsewell merged 1 commit intomasterfrom
parse_dynamic_functions in field/link configuration#1660chrisjsewell merged 1 commit intomasterfrom
Conversation
## Summary Mirrors the existing `parse_variants` exposure pattern to also expose `parse_dynamic_functions` as a user-configurable option on fields and links. Adds a new global config `needs_parse_dynamic_functions` (default `True`) to provide a phased migration path toward eventually defaulting to `False`. ## Motivation Previously, `parse_dynamic_functions` was hardcoded to `True` for all extra fields and links, with no way for users to disable it. This change gives users explicit control, and provides a single global knob to opt out of dynamic function parsing across the board. ## Changes **Config** (`sphinx_needs/config.py`): - Added `parse_dynamic_functions: bool | None` to `NewFieldParams`, `NeedFields`, `NeedLinksConfig`, and `_Config.add_field()` - Added `needs_parse_dynamic_functions` global config option (default `True`) to `NeedsSphinxConfig` **API** (`sphinx_needs/api/configuration.py`): - Added `parse_dynamic_functions` parameter to `add_field()` and `add_extra_option()` **Schema creation** (`sphinx_needs/needs.py`): - Extra fields and links now resolve `parse_dynamic_functions` from per-field config, falling back to the global `needs_parse_dynamic_functions` default (instead of hardcoded `True`) - Core field overrides pass `allow_dynamic_functions` to `create_inherited_field()` **Schema inheritance** (`sphinx_needs/needs_schema.py`): - `create_inherited_field()` now accepts and handles `allow_dynamic_functions`, gated by `allow_df` on core fields (same pattern as `parse_variants`/`allow_variants`) **Tests** (`tests/test_needs_schema.py`, `tests/test_dynamic_functions.py`): - Updated all existing `create_inherited_field` test calls with new required parameter - Added tests for `parse_dynamic_functions` override (allowed, rejected, invalid type) - Added integration test for `parse_dynamic_functions: false` on a field **Docs** (`docs/configuration.rst`, `docs/changelog.rst`): - Documented `parse_dynamic_functions` option under `needs_fields`, `needs_links`, and `needs_extra_links` - Added `needs_parse_dynamic_functions` config section with usage example - Added changelog entry ## Migration path | Phase | `needs_parse_dynamic_functions` default | Behavior | |-------|----------------------------------------|----------| | Now | `True` | Backward compatible; users can opt out per-field or globally | | Future major release | `False` | Dynamic function parsing requires explicit opt-in |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1660 +/- ##
==========================================
+ Coverage 86.87% 88.84% +1.96%
==========================================
Files 56 70 +14
Lines 6532 9976 +3444
==========================================
+ Hits 5675 8863 +3188
- Misses 857 1113 +256
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:
|
ubmarco
approved these changes
Feb 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Mirrors the existing
parse_variantsexposure pattern to also exposeparse_dynamic_functionsas a user-configurable option on fields and links. Adds a new global configneeds_parse_dynamic_functions(defaultTrue) to provide a phased migration path toward eventually defaulting toFalse.Motivation
Previously,
parse_dynamic_functionswas hardcoded toTruefor all extra fields and links, with no way for users to disable it. This change gives users explicit control, and provides a single global knob to opt out of dynamic function parsing across the board.Changes
Config (
sphinx_needs/config.py):parse_dynamic_functions: bool | NonetoNewFieldParams,NeedFields,NeedLinksConfig, and_Config.add_field()needs_parse_dynamic_functionsglobal config option (defaultTrue) toNeedsSphinxConfigAPI (
sphinx_needs/api/configuration.py):parse_dynamic_functionsparameter toadd_field()andadd_extra_option()Schema creation (
sphinx_needs/needs.py):parse_dynamic_functionsfrom per-field config, falling back to the globalneeds_parse_dynamic_functionsdefault (instead of hardcodedTrue)allow_dynamic_functionstocreate_inherited_field()Schema inheritance (
sphinx_needs/needs_schema.py):create_inherited_field()now accepts and handlesallow_dynamic_functions, gated byallow_dfon core fields (same pattern asparse_variants/allow_variants)Tests (
tests/test_needs_schema.py,tests/test_dynamic_functions.py):create_inherited_fieldtest calls with new required parameterparse_dynamic_functionsoverride (allowed, rejected, invalid type)parse_dynamic_functions: falseon a fieldDocs (
docs/configuration.rst,docs/changelog.rst):parse_dynamic_functionsoption underneeds_fields,needs_links, andneeds_extra_linksneeds_parse_dynamic_functionsconfig section with usage exampleMigration path
needs_parse_dynamic_functionsdefaultTrueFalse