-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
Improve taskflow type hints with ParamSpec #25173
Conversation
972bf54
to
be0aa11
Compare
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.
be0aa11
to
dcfa461
Compare
There was a problem hiding this 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
@@ -47,7 +47,7 @@ class SalesforceBulkOperator(BaseOperator): | |||
def __init__( | |||
self, | |||
*, | |||
operation: Literal[available_operations], | |||
operation: Literal['insert', 'update', 'upsert', 'delete', 'hard_delete'], |
There was a problem hiding this comment.
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
operation: Literal['insert', 'update', 'upsert', 'delete', 'hard_delete'], | |
operation: Literal[*available_operations], |
There was a problem hiding this comment.
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.
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 withCallable[FParams, FReturn]
so we can do polymorphism againstFParams
without being tied toFReturn
.