-
Notifications
You must be signed in to change notification settings - Fork 210
Closed
Labels
UserBugs reported by external users that should be prioritisedBugs reported by external users that should be prioritisedneeds-discussionAn issue where it's not clear whether there is a bug or we are behaving as expected.An issue where it's not clear whether there is a bug or we are behaving as expected.
Description
Describe the Bug
from types import TracebackType
from typing import overload
class CM:
def __enter__(self, /) -> None: ...
@overload
def __exit__(self, tp: None, ex: None, tb: None) -> None: ...
@overload
def __exit__(self, tp: type, ex: BaseException, tb: TracebackType) -> None: ...
def __exit__(self, tp: type | None, ex: BaseException | None, tb: TracebackType | None) -> None: ...
with CM():
passERROR sandbox.py:12:6-10: Cannot use `CM` as a context manager [[bad-context-manager](https://pyrefly.org/en/docs/error-kinds/#bad-context-manager)]
No matching overload found for function `CM.__exit__`
Possible overloads:
(tp: None, ex: None, tb: None) -> None [closest match]
(tp: type, ex: BaseException, tb: TracebackType) -> None
I realize that that this is tighter than how e.g. typeshed annotates __exit__, but I believe that it's correct like this.
Sandbox Link
(Only applicable for extension issues) IDE Information
No response
Metadata
Metadata
Assignees
Labels
UserBugs reported by external users that should be prioritisedBugs reported by external users that should be prioritisedneeds-discussionAn issue where it's not clear whether there is a bug or we are behaving as expected.An issue where it's not clear whether there is a bug or we are behaving as expected.