pyrefly
pyrefly copied to clipboard
Don't check return type for @overload and docstring
Describe the Bug
@overload with a docstring declaration is very handy - the ellipsis is handled correctly. However, @overload combined with a docstring is not handled properly.
from typing import *
@overload
def foo(a: str) -> str: # <-- Function declared to return `str` but is missing an explicit `return`
"""Docstring"""
@overload
def foo(a: int) -> int: ... # This is OK
def foo(*args, **kwargs) -> Any:
pass
Pyright doesn't report any errors in the code above.
Sandbox Link
No response
(Only applicable for extension issues) IDE Information
No response
@overload
def foo(a: str) -> str:
"""Docstring"""
... # <----
You can fix it by adding ...