Skip to content

Conversation

@LecrisUT
Copy link
Collaborator

This complements the discussion in #1050 that we should not allow some fields to be hard-coded. We should allow them in the context of overrides, so here is a rather convoluted way of adding that check.

This will also make it possible to extend it further if we want more specific checks for specific overrides matchers as well. E.g. we can add a restriction that build.requires cannot have @ in an sdist

@LecrisUT LecrisUT force-pushed the feat/no-hardcode-opts branch from a2504cc to 9922ae6 Compare May 14, 2025 15:13
@LecrisUT LecrisUT force-pushed the feat/no-hardcode-opts branch 3 times, most recently from 9a77549 to 417a6e7 Compare May 15, 2025 07:37
@henryiii henryiii force-pushed the feat/no-hardcode-opts branch 2 times, most recently from 53aed69 to f1a073a Compare July 3, 2025 21:45
@jcfr jcfr added this to the v0.12.0 milestone Sep 19, 2025
@jcfr jcfr force-pushed the feat/no-hardcode-opts branch from f1a073a to 4c114df Compare September 19, 2025 16:12
@henryiii henryiii force-pushed the feat/no-hardcode-opts branch from 4c114df to 404adc4 Compare October 13, 2025 19:55
@jcfr
Copy link
Contributor

jcfr commented Oct 17, 2025

Following discussion with @henryiii during Note from community meeting. Ideally, the schema should be updated before integrating.

LecrisUT and others added 6 commits November 19, 2025 15:51
Used for further validations

Signed-off-by: Cristian Le <[email protected]>
Add `test_disallow_hardcoded` to cover these type of settings

Signed-off-by: Cristian Le <[email protected]>
Signed-off-by: Henry Schreiner <[email protected]>
@henryiii henryiii force-pushed the feat/no-hardcode-opts branch from 982f3fc to d699403 Compare November 19, 2025 21:13
@henryiii henryiii requested a review from Copilot November 19, 2025 22:00
Copilot finished reviewing on behalf of henryiii November 19, 2025 22:13
Copy link
Contributor

Copilot AI left a 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 adds a mechanism to disallow hard-coding certain settings keys (like fail) in the top-level pyproject.toml, while still allowing them in override contexts. The fail field is the first to use this new override_only metadata flag.

Key Changes

  • Introduced override_only metadata field for settings that should only appear in overrides
  • Added validation logic to check for hard-coded override_only fields and warn/error accordingly
  • Updated fail field to use Optional[bool] with default None and marked as override_only

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/scikit_build_core/settings/skbuild_model.py Changed fail field to Optional[bool] with override_only=True metadata
src/scikit_build_core/settings/skbuild_overrides.py Added OverrideRecord dataclass and record_override function to track override history
src/scikit_build_core/settings/skbuild_read_settings.py Added _validate_overrides function to validate override_only fields
src/scikit_build_core/settings/skbuild_schema.py Updated schema generation to exclude override_only properties from top-level schema
src/scikit_build_core/settings/json_schema.py Added scikit-build:override-only marker to JSON schema properties
src/scikit_build_core/settings/documentation.py Added override_only field to DCDoc dataclass
src/scikit_build_core/settings/skbuild_docs_readme.py Filtered out override_only items from README documentation
src/scikit_build_core/resources/scikit-build.schema.json Removed default: false from fail property and updated schema structure
tests/test_settings_overrides.py Added test for disallow hardcoded functionality
tests/test_settings_docs.py Updated assertion to verify fail is not in documentation
docs/reference/configs.md Removed default value from fail configuration documentation
README.md Removed fail = false from example configuration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@henryiii henryiii force-pushed the feat/no-hardcode-opts branch from d699403 to e946c4e Compare November 19, 2025 22:23
@henryiii
Copy link
Collaborator

Note this is a very slight breaking change; if someone put fail = false explicitly at the top level, now that will be an error unless strictness is turned off. I think that's fine though, as it should be quite rare to do that, and easy to fix. We could put a workaround for this case for a while if really needed, though.

@henryiii henryiii merged commit 2910c15 into scikit-build:main Nov 21, 2025
66 checks passed
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