You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
This is more a coding concern for whom uses VSCode (and maybe other IDEs as well) and are trying to benefit from Pylance's strict type validations. The issue is that Pylance fail to validate Models with default field values when they are defined as a positional argument of Field, for example:
In the case of hera models this can be seen as:
Describe the solution you'd like
The solution for this is rather simple, just need to declare the default value as known-word argument in the models such as...
I understand the models are generated using datamodel-codegen and there's a flag called --use-default-kwarg which I believe will fix this issue
Describe alternatives you've considered
The alternative for the moment is to add a comment in the lines where this occur so type is ignored such as #type: ignore or #pyright: ignore but I wish to keep things clean and as much as possible respect types constrains throughout.
Some claim to be a bug, others that is a convoluted problem with the validation libraries... regardless, considering the issue has been closed for more than a year I suspect they are not changing any anytime soon.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
This is more a coding concern for whom uses VSCode (and maybe other IDEs as well) and are trying to benefit from Pylance's strict type validations. The issue is that Pylance fail to validate Models with default field values when they are defined as a positional argument of Field, for example:
In the case of hera models this can be seen as:
Describe the solution you'd like
The solution for this is rather simple, just need to declare the default value as known-word argument in the models such as...
I understand the models are generated using datamodel-codegen and there's a flag called
--use-default-kwarg
which I believe will fix this issueDescribe alternatives you've considered
The alternative for the moment is to add a comment in the lines where this occur so type is ignored such as
#type: ignore
or#pyright: ignore
but I wish to keep things clean and as much as possible respect types constrains throughout.Additional context
This issue or similar were discussed in the pydantic repo as in: pydantic/pydantic#3753 and pydantic/pydantic#3617
Some claim to be a bug, others that is a convoluted problem with the validation libraries... regardless, considering the issue has been closed for more than a year I suspect they are not changing any anytime soon.
The text was updated successfully, but these errors were encountered: