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

Fix return annotation of Observable.__await__ #630

Merged
merged 1 commit into from
Mar 13, 2022

Conversation

giff-h
Copy link
Contributor

@giff-h giff-h commented Mar 11, 2022

This fixes issues with mypy type checking when awaiting an observable

Here is an example output from await subject on mypy 0.940 (latest at time of PR opening)

tests/reactive/test_api_direct.py:1564: error: Incompatible types in "await" (actual type "Subject[Dict[str, Any]]", expected type "Awaitable[Any]")  [misc]
tests/reactive/test_api_direct.py:1564: note: Following member(s) of "Subject[Dict[str, Any]]" have conflicts:
tests/reactive/test_api_direct.py:1564: note:     Expected:
tests/reactive/test_api_direct.py:1564: note:         def __await__(self) -> Generator[Any, None, Any]
tests/reactive/test_api_direct.py:1564: note:     Got:
tests/reactive/test_api_direct.py:1564: note:         def __await__(self) -> Iterable[Dict[str, Any]]

@coveralls
Copy link

coveralls commented Mar 12, 2022

Coverage Status

Coverage increased (+0.0003%) to 93.363% when pulling 59beb65 on hamstap85:observable-await-typing into 3130ffc on ReactiveX:master.

@dbrattli
Copy link
Collaborator

Thanks for fixing this. Please ensure that you follow the developer guidelines before submitting a PR or you will need to make a lot of small fixes to get this passing the code checks i.e black, isort, ... Also note that generic Future is not supported in older versions of Python so you need to string the type i.e "Future[_T]"

@giff-h
Copy link
Contributor Author

giff-h commented Mar 12, 2022

@dbrattli Ah I thought that would get handled with from __future__ import annotations, I'll get an environment set up for local development tomorrow and fix it. I made this edit in the web editor so I didn't have a full setup yet.

Also I made the switch_map operator because I needed it for my current project, drawing inspiration from the definition in rxjs, if you'd like me to submit a draft for that.

@dbrattli
Copy link
Collaborator

@hamstap85 You are right about from __future__ import annotations fixing this.

@dbrattli
Copy link
Collaborator

Please feel free to submit a PR for switch_map with tests and docs

This fixes issues with mypy type checking when awaiting an observable
@giff-h giff-h force-pushed the observable-await-typing branch from 9e37722 to 59beb65 Compare March 12, 2022 21:45
@giff-h
Copy link
Contributor Author

giff-h commented Mar 12, 2022

@dbrattli updated

Copy link
Collaborator

@dbrattli dbrattli left a comment

Choose a reason for hiding this comment

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

Thanks for fixing!

@dbrattli dbrattli merged commit a227802 into ReactiveX:master Mar 13, 2022
@giff-h giff-h deleted the observable-await-typing branch March 13, 2022 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants