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
A solution is to double-specify the type in the class field declaration:
class SulciLabling(Controller):
labeled_graph: File = field(type_=File, write=True, doc='output labeled graph')
but it needs to say things twice, is error prone, and it was not designed to be this way.
I don't know (or don't remember) how class fields are assigned in the 1st form: field() returns a Field instance without a type set, then it seems to be modified when assigned to the typed class variable labeled_graph, but I don't know where and if we can do anything there to fix things ?
The consequence of this bug is that, in capsul, tests done in fields like: if field.path_type are sometimes wrong and unreliable.
The text was updated successfully, but these errors were encountered:
I already noticed (and forgot) problems using this syntax. I now believe that the syntax is wrong since the affectation should contain a value not a type. The right syntax should be:
class SulciLabling(Controller):
labeled_graph: field(type_=File, write=True, doc='output labeled graph')
I am in favor of raising an error when the value set on a controller attribute is a Field. What do you think ?
In pydantic Controller, we can declare a class field this way:
However the
field()
function, in this case, is called without atype_
argument, and metadata are not initialized properly:see:
path_type
isNone
, not'file'
If we use:
then the metadata are:
A solution is to double-specify the type in the class field declaration:
but it needs to say things twice, is error prone, and it was not designed to be this way.
I don't know (or don't remember) how class fields are assigned in the 1st form:
field()
returns aField
instance without atype
set, then it seems to be modified when assigned to the typed class variablelabeled_graph
, but I don't know where and if we can do anything there to fix things ?The consequence of this bug is that, in capsul, tests done in fields like:
if field.path_type
are sometimes wrong and unreliable.The text was updated successfully, but these errors were encountered: