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

Template typing in task interfaces #672

Open
tclose opened this issue Jul 1, 2023 · 1 comment
Open

Template typing in task interfaces #672

tclose opened this issue Jul 1, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@tclose
Copy link
Contributor

tclose commented Jul 1, 2023

What would you like changed/added and why?

The ability to use template types (i.e. typing.TypeVar) when defining task interfaces, e.g.

@mask.task
def mytask(x: typing.T) -> typing.T:
    ...

What would be the benefit? Does the change make something easier to use?

The most important benefit would be to enable you to specify that a task operates on a generic object/files but returns the same type as it was passed

What would be required

  • When passed a type-var, TypeParser checks the type-var's "bound-type"
  • When defining an output-spec, check that any type-vars referenced in it are referenced in the input-spec
  • When initialising inputs, check whether all type-var types can be resolved to a single type (respecting the bound-types of the type-vars)
  • When accessing lazy-outputs of a task resolve any type-var types from their resolved values in the input-spec
    • Check that all type-var inputs have been already specified
    • Guard against input template type changes if the lzout attribute has already been generated
  • When initialising outputs type-check against their resolved types
@tclose tclose added the enhancement New feature or request label Jul 1, 2023
@tclose
Copy link
Contributor Author

tclose commented Jul 1, 2023

@effigies I think this is all that would be required to add support for template typing, probably something that could be looked at in a future hack-week

@tclose tclose mentioned this issue Aug 1, 2023
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant