Replies: 5 comments
-
Hey Tom, thanks for taking the time to put all this in writing. I too believe a proper discussion around type safety in workflows is worth having. |
Beta Was this translation helpful? Give feedback.
-
perhaps we can have some discussion today during the meeting |
Beta Was this translation helpful? Give feedback.
-
Agree. We should not change the behavior of other packages. If we need to (optionally) disable it in particular places, we should do so with a context manager to keep the scope clear and limited.
I'd worry about moving the semantics too far from type annotations. Would it work to use something like: task2.inputs.in1 = cast(TargetType, task1.lzout.out) Which could be something like: def cast(tgt_type: type[T] | Callable[[V], T], value: Future[V]) -> Future[T]:
... The default behavior would be to use normal typing rules, but any conversion could be supported in principle and we could even check the types of the source, destination and converter. |
Beta Was this translation helpful? Give feedback.
-
Attrs has a special status in mypy: https://mypy.readthedocs.io/en/stable/additional_features.html#the-attrs-package |
Beta Was this translation helpful? Give feedback.
-
comments from the discussion:
|
Beta Was this translation helpful? Give feedback.
-
I wanted to spell out what I had in mind for type-checking in a bit more detail ahead of the developers meeting tomorrow, but it is late so I will just try to jot down some ideas in point-form.
attrs
validators inpydra.__init__
(at least by default).attrs
fileformats
DestFileFormat(src_file_format_object)
will attempt to reinterpret the file-system paths insrc_file_format_object
as aDestFileFormat
Path
,str
and will perform file-format checkingissubtype
of SrcFileFormatissubclass
DicomDir[Dwi, Brain, Human]
, andissubtype
is able to work out thatDicomDir[Dwi, Brain, Human]
is a subtype ofDicomDir[Dwi, Brain]
Anyway, I'm not sure if that all makes sense, but I need to get to bed :)
Beta Was this translation helpful? Give feedback.
All reactions