Invalid type inference in a conditional context manager with contextlib.nullcontext()
.
#16264
Labels
contextlib.nullcontext()
.
#16264
Bug Report
When a ternary is used in a
with
or anasync 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
The text was updated successfully, but these errors were encountered: