-
-
Notifications
You must be signed in to change notification settings - Fork 543
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
Deprecate strawberry.union('name', types=(A, B)) in favour of using Annoted #521
Comments
what about this requires a mypy extension? Or does the usage of |
@BryceBeagle so, we need the plugin to tell mypy that result now is a Type, more specifically a Unfortunately our current plugin seems to break in some cases, and I'm having a hard time finding a solution, basically here: one of the type breaks |
Does PEP-613 not work for this case? Result: TypeAlias = strawberry.union("Result", (A, B, C)) |
@BryceBeagle didn't know about that one! I think the problem would still be that mypy doesn't know the actual type of Result :( |
Oh well, turns out we can't do this for now, as mypy doesn't support it, from python/mypy#9315
|
We might not deprecate |
@patrick91 has a new annotated version been released yet or is |
we are keeping strawberry.union 😊 |
Can we close this issue then @patrick91 ? |
let's close for now, maybe we'll come back to it in future 😊 |
So, I though having our own way of defining union type was a good idea, but turns out it is quite hard to make a mypy plugin that understands this syntax:
also this won't really be supported in other type checkers, so the alternative is this:
which is not that bad, also this allows to define named unions on fields directly:
which isn't the best thing to ready, but might be useful in some cases :D
The text was updated successfully, but these errors were encountered: