Skip to content

Conversation

@chrisjsewell
Copy link
Member

@chrisjsewell chrisjsewell commented Dec 22, 2025

This pull request introduces support for a nullable property in need field definitions, allowing fields to be explicitly marked as allowing or disallowing unset (None) values. The changes affect the configuration, schema validation, and documentation, and include updates to both the codebase and the test suite to ensure correct handling and enforcement of field nullability.

For example:

needs_fields = {
   "introduced": {
      "description": "Date when the need was introduced",
      "schema": {
         "type": "string",
         "format": "date",
      },
      "nullable": False,
   },
}

@chrisjsewell chrisjsewell requested a review from ubmarco December 22, 2025 20:55
@codecov
Copy link

codecov bot commented Dec 22, 2025

Codecov Report

❌ Patch coverage is 97.50000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 88.24%. Comparing base (4e10030) to head (975e42a).
⚠️ Report is 221 commits behind head on master.

Files with missing lines Patch % Lines
sphinx_needs/needs_schema.py 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1613      +/-   ##
==========================================
+ Coverage   86.87%   88.24%   +1.36%     
==========================================
  Files          56       70      +14     
  Lines        6532     9929    +3397     
==========================================
+ Hits         5675     8762    +3087     
- Misses        857     1167     +310     
Flag Coverage Δ
pytests 88.24% <97.50%> (+1.36%) ⬆️

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.

If specified, the field value will be validated against this schema when needs are parsed, see :ref:`schema_validation` for more details.
By default the field schema will be ``{"type": "string"}``.
- ``nullable``: If set to ``True``, the field can be set to ``None`` (optional), e.g. if no value is specifically given and no default applies,
If ``False``, the field must have a value (either explicitly set or via default/predicates), otherwise the need is invalid and will not be created.
Copy link
Member

Choose a reason for hiding this comment

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

How would users know the default for nullable? This depends on the field, we should state this somewhere.

Copy link
Member Author

Choose a reason for hiding this comment

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

Obviously, this is only for inherited core fields, but yes we should show their "full" configuration in the needs_fields documentation.
Maybe leave this for a follow-up PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

@chrisjsewell chrisjsewell marked this pull request as ready for review December 23, 2025 08:25
@chrisjsewell chrisjsewell requested a review from ubmarco December 23, 2025 08:28
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, thanks for the update

@chrisjsewell chrisjsewell merged commit f0b9fbd into master Dec 23, 2025
22 checks passed
@chrisjsewell chrisjsewell deleted the nullable-config branch December 23, 2025 22:03
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.

3 participants