From b5cf9e4ddc6fd2585e0a9e202e8feae236ffc3d4 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 11 Jan 2026 11:19:39 -0800 Subject: [PATCH 1/2] sre_compile: use TypeIs --- stdlib/sre_compile.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/sre_compile.pyi b/stdlib/sre_compile.pyi index e29d63d48591..b8388f6aa8e5 100644 --- a/stdlib/sre_compile.pyi +++ b/stdlib/sre_compile.pyi @@ -3,7 +3,7 @@ from sre_constants import * from sre_constants import _NamedIntConstant from sre_parse import SubPattern from typing import Any, Final, Literal, overload -from typing_extensions import TypeGuard +from typing_extensions import TypeIs MAXCODE: Final[int] @@ -11,5 +11,5 @@ def dis(code: list[_NamedIntConstant]) -> None: ... @overload def isstring(obj: str | bytes) -> Literal[True]: ... @overload -def isstring(obj: object) -> TypeGuard[str | bytes]: ... +def isstring(obj: object) -> TypeIs[str | bytes]: ... def compile(p: str | bytes | SubPattern, flags: int = 0) -> Pattern[Any]: ... From cff6e8d8a083a03db76cb5a9270571fcdbbc0e70 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 11 Jan 2026 14:46:41 -0800 Subject: [PATCH 2/2] simplify --- stdlib/sre_compile.pyi | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/stdlib/sre_compile.pyi b/stdlib/sre_compile.pyi index b8388f6aa8e5..486b2f743eeb 100644 --- a/stdlib/sre_compile.pyi +++ b/stdlib/sre_compile.pyi @@ -2,14 +2,11 @@ from re import Pattern from sre_constants import * from sre_constants import _NamedIntConstant from sre_parse import SubPattern -from typing import Any, Final, Literal, overload +from typing import Any, Final from typing_extensions import TypeIs MAXCODE: Final[int] def dis(code: list[_NamedIntConstant]) -> None: ... -@overload -def isstring(obj: str | bytes) -> Literal[True]: ... -@overload def isstring(obj: object) -> TypeIs[str | bytes]: ... def compile(p: str | bytes | SubPattern, flags: int = 0) -> Pattern[Any]: ...