Skip to content

👌 Expose parse_dynamic_functions in field/link configuration#1660

Merged
chrisjsewell merged 1 commit intomasterfrom
parse_df
Feb 19, 2026
Merged

👌 Expose parse_dynamic_functions in field/link configuration#1660
chrisjsewell merged 1 commit intomasterfrom
parse_df

Conversation

@chrisjsewell
Copy link
Member

@chrisjsewell chrisjsewell commented Feb 19, 2026

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

## 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 |
@chrisjsewell chrisjsewell requested a review from ubmarco February 19, 2026 16:26
@codecov
Copy link

codecov bot commented Feb 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.84%. Comparing base (4e10030) to head (5a32480).
⚠️ Report is 253 commits behind head on master.

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     
Flag Coverage Δ
pytests 88.84% <100.00%> (+1.96%) ⬆️

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.

@chrisjsewell chrisjsewell merged commit aa1d284 into master Feb 19, 2026
24 of 25 checks passed
@chrisjsewell chrisjsewell deleted the parse_df branch February 19, 2026 18:53
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