Skip to content
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

MNT: Relaxing lazy-field type-checking to permit super types to be passed to sub-type fields #682

Open
tclose opened this issue Aug 2, 2023 · 0 comments
Labels
maintenance Refactors and improvements to code quality.

Comments

@tclose
Copy link
Contributor

tclose commented Aug 2, 2023

With the motivation of keeping the typing infrastructure out of the way of new users I have been considering relaxing the type-checking at construction time (i.e. lazy fields) so that base classes can be passed to sub-classed type fields. This will avoid need to add cast statements between loosely-typed tasks and tightly-typed tasks. Stricter type-checking/coercing can still be performed at runtime.

For example, if B is a subclass of A, then currently you can connect a B-typed output into a A-typed input but if you wanted to connect A-typed to B-typed you would need to cast it to B first. While this aligns with how traditional type-checking is done, we might want to be a bit more flexible so you could connect generic File type fields to Nifti fields for example. If both upstream and downstream nodes use to specific formats that don't match, e.g. MrtrixImage -> Nifti then we would still raise an error.

It would somewhat reduce the effectiveness of the type-checking, but would probably avoid any (false-positive) cases where the type-checking could be annoying

@tclose tclose added the maintenance Refactors and improvements to code quality. label Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Refactors and improvements to code quality.
Projects
None yet
Development

No branches or pull requests

1 participant