-
Notifications
You must be signed in to change notification settings - Fork 17
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
Make it possible to know about "unknown" keys that might be set in [project]
table
#12
Comments
Actually, we should go one step further and try to identify typos like in https://github.com/pypa/build/blob/96f9188ad181907fbd3e0efdf32dd3dc959d39c3/src/build/__init__.py#L177. |
As long as the caller is able to control how these would be presented, it'd satisfy my usecases! The use case: In https://github.com/pradyunsg/sphinx-theme-builder, all output is piped through a |
Well, I intended to raise a warning, like pypa/build. You can specify your own custom warning handler by overwriting |
Sounds good to me! |
Thinking about this a bit more... I think it would be great if the warning object has the "unknown" keys accessible directly as an attribute. |
Based on a more recent usecase and "interaction with the real world", I would prefer that this be a validation error instead; since a build-backend should error out if it gets metadata here that's not declared properly. If someone wants to allow for permissive parsing, I don't imagine they would be using this library for that. |
The main worry there would be due to backwards compatibility in Looking into this a bit more, I think a reasonable compromise would be to keep it a warning, but to add a filter to promote it to error by default. This way it would result in an error under normal situations, but still allow users to use What do you think? |
That sounds reasonable to me. In most libraries adding a filter by default would be frowned, but it shouldn't matter here because usages of It seems difficult to introduce new keys in |
IMO, unlike build, which has to process any backend, this is mostly used by backends. So if a key isn't recognized, then it's not being handled, because we are the ones handling it. For example, on the new PEP 639 license fields: we current don't handle it, so users (scikit-build-core, meson-python, and pdm.backend) can't use it in combination with pyproject-metadata. Setting license to string throws an error. And setting license-files to anything doesn't put it into the RFC metadata; it just silently does the wrong thing! And typos are very common. I found thousands of typos in my download of all pyproject.tomls on PyPI. If a build backend wants to support new fields, they can pre-process the input. That way they can manually handle some new field without having it I think just making this an error is fine. Though we could have build backends opt-in by calling a |
Also, the current state is inconsistent: arbitrary keys like |
Inspired by pypa/flit#505.
The text was updated successfully, but these errors were encountered: