-
Notifications
You must be signed in to change notification settings - Fork 897
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
bad-exit-annotation
(PYI036
) triggers on typing.overload
definitions
#11044
Comments
@AlexWaygood - do you mind taking this one? |
Yeah, good call — I think we should just skip any functions decorated with |
On second thought, we can provide some validation for overloaded functions. Slightly more fiddly, but definitely doable. |
Thanks Alex! |
Some "related off-topic" from me, since I recently went through a similar thing. There should be no need to write overloads if we return from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from _typeshed import OptExcInfo # tuple[None, None, None] | tuple[type[BaseException], BaseException, TracebackType]
from typing_extensions import Unpack
class Foo:
def __exit__(self, *args: Unpack[OptExcInfo]) -> None: # should be legal, but isn't
pass What Ruff might or might not want to do is allow unpacking |
Keywords searched in the issue tracker: PYI036, overload
Running
ruff check --select PYI036 --isolated
using Ruff version 0.4.0 on the fileproduces six
PYI036
errors (three for each overload definition). The expected behaviour is that noPYI036
errors are raised, as these are overloads that describe legal calls rather than the complete implementation. This approach was recommended on this blog post.The text was updated successfully, but these errors were encountered: