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

Invalid type inference in a conditional context manager with contextlib.nullcontext(). #16264

Closed
francis-clairicia opened this issue Oct 14, 2023 · 1 comment
Labels
bug mypy got something wrong topic-join-v-union Using join vs. using unions

Comments

@francis-clairicia
Copy link

Bug Report

When a ternary is used in a with or an async with statement to determine the final context manager, mypy cannot infer the expression type.

To Reproduce

https://mypy-play.net/?mypy=latest&python=3.11&gist=a2db21d63361bc0f1f334ff337509fca

Expected Behavior

The expression should lead to TaskGroup type.

Actual Behavior

The expression lead to object type.

Your Environment

  • Mypy version used: 1.6.0
@francis-clairicia francis-clairicia added the bug mypy got something wrong label Oct 14, 2023
@AlexWaygood AlexWaygood added the topic-join-v-union Using join vs. using unions label Oct 14, 2023
@AlexWaygood
Copy link
Member

Duplicate of #10109 and #5512

@AlexWaygood AlexWaygood closed this as not planned Won't fix, can't repro, duplicate, stale Oct 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-join-v-union Using join vs. using unions
Projects
None yet
Development

No branches or pull requests

2 participants