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

__{a}exit__ typing #874

Closed
3 tasks done
peterschutt opened this issue Feb 29, 2024 · 0 comments · Fixed by #875
Closed
3 tasks done

__{a}exit__ typing #874

peterschutt opened this issue Feb 29, 2024 · 0 comments · Fixed by #875
Labels

Comments

@peterschutt
Copy link
Contributor

Things to check first

  • I have checked that my issue does not already have a solution in the FAQ

  • I have searched the existing issues and didn't find my bug already reported there

  • I have checked that my bug is still present in the latest release

Version

4.0.0a4

What happened?

Passing an AsyncScheduler instance to AsyncExitStack.enter_async_context results in:

src/infra/__init__.py:61: error: Argument 1 to "enter_async_context" of "AsyncExitStack" has incompatible type "AsyncScheduler"; expected "AbstractAsyncContextManager[AsyncScheduler]"  [arg-type]
src/infra/__init__.py:61: note: Following member(s) of "AsyncScheduler" have conflicts:
src/infra/__init__.py:61: note:     Expected:
src/infra/__init__.py:61: note:         def __aexit__(self, type[BaseException] | None, BaseException | None, TracebackType | None, /) -> Coroutine[Any, Any, bool | None]
src/infra/__init__.py:61: note:     Got:
src/infra/__init__.py:61: note:         def __aexit__(self, type[BaseException], BaseException, TracebackType, /) -> Coroutine[Any, Any, None]

To conform to the ABC the args received by the exit method must be union with None.

How can we reproduce the bug?

    async with AsyncExitStack() as stack:
        scheduler = AsyncScheduler()
        scheduler = await stack.enter_async_context(scheduler)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant