Skip to content

Commit 22c45eb

Browse files
committed
fix test for async functions
1 parent dc9ee31 commit 22c45eb

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

python/code/wypp/location.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ def getResultTypeLocation(self) -> Optional[Loc]:
201201
@abc.abstractmethod
202202
def getParamSourceLocation(self, paramName: str) -> Optional[Loc]:
203203
pass
204+
@property
205+
@abc.abstractmethod
206+
def isAsync(self) -> bool:
207+
pass
204208

205209
class StdCallableInfo(CallableInfo):
206210
"""
@@ -276,6 +280,10 @@ def getParamSourceLocation(self, paramName: str) -> Optional[Loc]:
276280
res.end_lineno,
277281
res.end_col_offset)
278282

283+
@property
284+
def isAsync(self) -> bool:
285+
node = self._findDef()
286+
return isinstance(node, ast.AsyncFunctionDef)
279287

280288
def classFilename(cls) -> str | None:
281289
"""Best-effort path to the file that defined `cls`."""
@@ -315,6 +323,9 @@ def getParamSourceLocation(self, paramName: str) -> Optional[Loc]:
315323
return Loc(file, node.lineno, node.col_offset, node.end_lineno, node.end_col_offset)
316324
else:
317325
return None
326+
@property
327+
def isAsync(self) -> bool:
328+
return False
318329

319330
def locationOfArgument(fi: inspect.FrameInfo, idxOrName: int | str) -> Optional[Loc]:
320331
"""

python/code/wypp/typecheck.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ def raiseArgMismatch():
126126

127127
def checkReturn(sig: inspect.Signature, returnFrame: Optional[inspect.FrameInfo],
128128
result: Any, info: location.CallableInfo, cfg: CheckCfg) -> None:
129+
if info.isAsync:
130+
return
129131
t = sig.return_annotation
130132
if isEmptyAnnotation(t):
131133
t = None

0 commit comments

Comments
 (0)