Closed as not planned
Closed as not planned
Description
Bug Report
Mypy 1.8 seems to be failing to combine prompt-toolkit
's ProgressBar
with contextlib.nullcontext()
into a context manager object.
To Reproduce
import contextlib
from prompt_toolkit.shortcuts import ProgressBar
debug_print: bool = True
cm = ProgressBar() if debug_print else contextlib.nullcontext()
reveal_type(cm) # Revealed type is "builtins.object"
with cm:
pass
Expected Behavior
No type errors
Actual Behavior
a.py:7:13: note: Revealed type is "builtins.object"
a.py:8:6: error: "object" has no attribute "__enter__" [attr-defined]
a.py:8:6: error: "object" has no attribute "__exit__" [attr-defined]
Your Environment
- Mypy version used: 1.8
- Mypy command-line flags:
- Mypy configuration options from
mypy.ini
(and other config files): - Python version used: 3.12.1