-
-
Notifications
You must be signed in to change notification settings - Fork 91
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
Allow passing multiple events to the @listen decorator #1103
Allow passing multiple events to the @listen decorator #1103
Conversation
Ideally, the origin of the annotation should be checked too in case a type with |
This works with all python versions we support, as it never actually checks for the union. It just expands the arguments of the annotation using a typing function, which will support each python version |
Oops, I wanted to suggest also checking the origin for the edge cases when the passed-in type is not a union. 😅 |
In the case it is not a union, it will get expanded as far as it can go and then passed onto subscribe. Subscribe will then make the necessary checks and error accordingly |
Also this needs a changelog entry |
bbec9c8
to
b5d858a
Compare
Linting is failing |
b5d858a
to
ecaf665
Compare
Lining failing due to psf/black#2964 Will be fixed by updating black to the latest version, which I will open a PR for in a sec. Then this PR should be rebased Relevant PR: #1114 |
Rework checking event type in subscribe Make sure type is a Union before calling get_args Add test case for invalid type in type hints
ecaf665
to
c5d41af
Compare
Summary
This pull requests allows passing multiple events to the listen decorator.
Alternatively, a Union can be used in the type hint to achieve the same thing.
Checklist
nox
and all the pipelines have passed.Flake8 session is failing - but it was on master before I touched anything.