-
-
Notifications
You must be signed in to change notification settings - Fork 183
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
Hint about extra fields in conda-forge.yml #1920
base: main
Are you sure you want to change the base?
Conversation
conda_smithy/lint_recipe.py
Outdated
@@ -1,6 +1,11 @@ | |||
# -*- coding: utf-8 -*- | |||
|
|||
from collections.abc import Sequence, Mapping | |||
from typing import List | |||
|
|||
from pydantic import BaseModel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@isuruf Let's continue the discussion about adding pydantic here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way: pydantic
is already listed as a project dependency in environment.yml
Edit: This comment does not contribute to the discussion, my mistake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For clarity pydantic
is a development-only dependency. So that only affects development, not installation. We generate a JSON schema for runtime use. For context, it was added in PR: #1756
Is it possible to use jsonschema
for this case too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that pydantic is not currently a part of https://github.com/conda-forge/conda-smithy-feedstock/blob/main/recipe/meta.yaml dependencies.
I am not aware of a good way of doing this with jsonschema
.
Also, I want to repeat my argument:
I would like and strongly propose to keep pydantic here. Pydantic provides an elegant way to find additional fields that are not part of the schema (see my implementation) - and also, I think the pydantic model should be used in more parts of the smithy code anyway since it provides a type-safe way to access fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is adding pydantic
as a new dependency so bad?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is adding pydantic as a new dependency so bad?
Please see my comment on the other thread.
I am not aware of a good way of doing this with jsonschema.
This is easy. Load the json schema and see if "additionalProperties": false
is there for the attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see my comment on the other thread.
@isuruf I just scrolled through every comment you left at my conda-smithy PRs but could not find an answer to my question. You said:
This adds a new dependency pydantic on users. Previously it was only a dev dependency. Is it possible to remove this?
and
I strongly disagree. This PR use pydantic to check for which fields to hint about. If we can't do that using the json schema we are essentially making a distinction between pydantic model and json schema.
I do not see how this explains why we want to avoid pydantic
as a dependency. To your latter comment, I replied:
What do you mean with "distinction"? The pydantic model should be equivalent to the JSON schema anyway - if it's not, we have a bug.
This is easy. Load the json schema and see if "additionalProperties": false is there for the attribute.
This requires us to have a separate JSON schema that actually has additionalProperties
set to false for the fields we want to warn about since we have agreed to allow additional properties in the main schema. Is this what you propose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@isuruf I would really really like to solve this debate as I want this PR to get merged.
Note: The signature of We had a discussion about deprecation in #1906 |
What is the status of this PR? @conda-forge/core @isuruf |
036d3df
to
155b56e
Compare
@isuruf There are still some open discussions about pydantic |
don't warn for AzureRunnerSettings and CondaBuildConfig
155b56e
to
8a429ed
Compare
@isuruf You did not reply here since almost 2 months although I pinged you multiple times. Is there anything I need to do? Fine of course if you're currently busy, I'll wait here. |
aca42c0
to
1a129f6
Compare
1a129f6
to
bfc6a4b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue here is requiring pydantic at run time IIRC. We need to resolve this sticking point before we can merge.
What exactly is the reason that we don't want to have pydantic as a runtime dependency? |
I thought I made my reasons clear in #1900. Let me know if you need more clarification. |
Looking at that PR, the only relevant-looking thread I see is
So the sticking point is not having a runtime dependence on |
No, the main point is that I want the json schema to be complete.
|
How do you imagine we encode the fact that additional fields are forbidden in the json schema? AFAICT json has no way to specify that, so whatever we do, we'd have to introduce a marker-field that says "this JSON schema cannot be extended". Which is what this PR is doing with To me saying "json schema needs to be complete" thus becomes equivalent to "we shouldn't lint on unknown fields", which I strongly disagree with. |
|
So the issue is just the choice of default? I.e. whether we need to add It'd be completely fine for me to opt into |
Yes, but with a |
I don't care personally. I was trying to make sure more discussion was had since others had objected. |
Checklist
news
entryThis PR contains the functional changes of #1900, to be merged separately. See also parts of the discussion there.
TLDR:
recipe-lint
now hints about additional fields as compared with the Pydantic schema.