-
Notifications
You must be signed in to change notification settings - Fork 2
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
sample use case: return type of @contextmanager
decorated functions
#15
Comments
The best I came up with was using if TYPE_CHECKING:
@contextmanager
def foo() -> Iterator[Never]:
...
else:
def foo():
...
return _hoge() |
Yap, exactly that. It is clearly not meant to be exported from contextlib.
I think not exposing such implementation detail is good. That way, we can later swap the implementation |
I want to contribute a real life use case that we encountered which may justify the needs of Intersection types.
Can anyone suggest an alternative without using Intersection?
NOTE: the spec of
@contextmanager
is here:https://docs.python.org/3/library/contextlib.html#contextlib.contextmanager
Essentially, what the decorated function returns is a ContextManager that uses ContextDecorator mixin.
The text was updated successfully, but these errors were encountered: