Skip to content

Conversation

@uranusjr
Copy link
Member

@uranusjr uranusjr commented Jul 20, 2022

This needs #25085 to be merged first. Only the last commit is relevant.

Submitted for CI now.

This should be ready. I needed to fix a few more (valid although unrelated) typing issues since Mypy started to flag them.

The main thing here is to replace the Function type var with Callable[FParams, FReturn] so we can do polymorphism against FParams without being tied to FReturn.

@uranusjr uranusjr force-pushed the taskflow-xcom-arg-typehint branch from 972bf54 to be0aa11 Compare July 25, 2022 04:27
@uranusjr uranusjr marked this pull request as ready for review July 25, 2022 04:27
uranusjr added 2 commits July 26, 2022 15:22
This is made available with our latest Mypy update. ParamSpec allows us
to more accurately type a decorated task to return an XComArg (while
still being correctly typed to accept the same arguments as the
decorated function). This allows us to provide autocompletion for
XComArg operations, such as map() and zip() introduced in AIP-42.
@uranusjr uranusjr force-pushed the taskflow-xcom-arg-typehint branch from be0aa11 to dcfa461 Compare July 26, 2022 07:22
Copy link
Member

@ashb ashb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question. LGTM otherwise if that's not possible

self,
*,
operation: Literal[available_operations],
operation: Literal['insert', 'update', 'upsert', 'delete', 'hard_delete'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not possible to do

Suggested change
operation: Literal['insert', 'update', 'upsert', 'delete', 'hard_delete'],
operation: Literal[*available_operations],

Copy link
Member Author

@uranusjr uranusjr Jul 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python syntactically does not allow using * in brackets. The previous Literal[available_operations] is valid Python but PEP 586 considered this out of scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dev-tools type:improvement Changelog: Improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants