Skip to content

Commit 9840c58

Browse files
authored
[sre_compile] Use TypeGuard for isstring (#15250)
1 parent e213e04 commit 9840c58

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

stdlib/sre_compile.pyi

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ from re import Pattern
22
from sre_constants import *
33
from sre_constants import _NamedIntConstant
44
from sre_parse import SubPattern
5-
from typing import Any, Final
5+
from typing import Any, Final, Literal, overload
6+
from typing_extensions import TypeGuard
67

78
MAXCODE: Final[int]
89

910
def dis(code: list[_NamedIntConstant]) -> None: ...
10-
def isstring(obj: Any) -> bool: ...
11+
@overload
12+
def isstring(obj: str | bytes) -> Literal[True]: ...
13+
@overload
14+
def isstring(obj: object) -> TypeGuard[str | bytes]: ...
1115
def compile(p: str | bytes | SubPattern, flags: int = 0) -> Pattern[Any]: ...

0 commit comments

Comments
 (0)