You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
python/cpython#125862 describes some problems that can occur when applying a ContextDecorator to an async function or a generator function. Is it reasonable to add overloads returning Never for such cases, so that typecheckers can warn people?
The code in question runs, but it doesn't do anything useful let alone have the expected effect, so I'd love to warn about it sooner than CPython will release a fix.
The text was updated successfully, but these errors were encountered:
Returning Never isn't the right solution for overloads that we want users to avoid; it makes type checkers treat code as unreachable, which can have rather confusing effects. However, we may be able to use @deprecated, especially if CPython also deprecates these behaviors.
Yes, when we've tried these kinds of -> Never overloads in the past it's almost always caused more trouble than it's worth, unfortunately (see #8566 for an example)
Zac-HD
changed the title
Overloads with -> Never for invalid uses of contextlib.ContextDecorator?@deprecated overloads for invalid uses of contextlib.ContextDecorator?
Oct 23, 2024
python/cpython#125862 describes some problems that can occur when applying a
ContextDecorator
to an async function or a generator function. Is it reasonable to add overloads returningNever
for such cases, so that typecheckers can warn people?The code in question runs, but it doesn't do anything useful let alone have the expected effect, so I'd love to warn about it sooner than CPython will release a fix.
The text was updated successfully, but these errors were encountered: