Back to Ruff

TypeError: 'int' object does not support the context manager protocol

crates/ty_python_semantic/resources/lint_docs/invalid-context-manager.md

0.15.18321 B
Original Source

What it does

Checks for expressions used in with statements that do not implement the context manager protocol.

Why is this bad?

Such a statement will raise TypeError at runtime.

Examples

python
# TypeError: 'int' object does not support the context manager protocol
with 1:  # error
    print(2)