-
Notifications
You must be signed in to change notification settings - Fork 238
Labels
good first issueGood for newcomersGood for newcomersnarrowingIssues with narrowing - root cause is usually narrowing, flow handling, or bothIssues with narrowing - root cause is usually narrowing, flow handling, or bothtypechecking
Description
Describe the Bug
from typing import TypeGuard
def is_int(x: int | str) -> TypeGuard[int]:
return isinstance(x, int)
class X:
def __init__(self, param: int | str):
self.param = param
def has_int(self):
return is_int(self.param)This reports X::has_int as an invalid TypeGuard function, because it is detected to return a TypeGuard, and has no parameters. Seems to work fine if the function does not always return the typeguard.
Sandbox Link
(Only applicable for extension issues) IDE Information
No response
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomersnarrowingIssues with narrowing - root cause is usually narrowing, flow handling, or bothIssues with narrowing - root cause is usually narrowing, flow handling, or bothtypechecking