Skip to content

Commit 2a97098

Browse files
authored
Merge branch 'main' into typeform-generic-classgetitem
2 parents 94754a0 + bfcf8df commit 2a97098

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

requirements-tests.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Type checkers that we test our stubs against. These should always
22
# be pinned to a specific version to make failure reproducible.
3-
mypy==2.0.0
3+
mypy==2.1.0
44
pyright==1.1.409
55

66
# Libraries used by our various scripts.

stdlib/string/templatelib.pyi

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
from collections.abc import Iterator
22
from types import GenericAlias
3-
from typing import Any, Literal, TypeVar, final, overload
3+
from typing import Any, Generic, Literal, TypeVar, final, overload
44
from typing_extensions import TypeForm
55

66
_T = TypeVar("_T")
77

88
@final
99
class Template: # TODO: consider making `Template` generic on `TypeVarTuple`
1010
strings: tuple[str, ...]
11-
interpolations: tuple[Interpolation, ...]
11+
interpolations: tuple[Interpolation[Any], ...]
1212

13-
def __new__(cls, *args: str | Interpolation) -> Template: ...
14-
def __iter__(self) -> Iterator[str | Interpolation]: ...
13+
def __new__(cls, *args: str | Interpolation[Any]) -> Template: ...
14+
def __iter__(self) -> Iterator[str | Interpolation[Any]]: ...
1515
def __add__(self, other: Template, /) -> Template: ...
1616
def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ...
1717
@property
1818
def values(self) -> tuple[Any, ...]: ... # Tuple of interpolation values, which can have any type
1919

2020
@final
21-
class Interpolation:
22-
value: Any # TODO: consider making `Interpolation` generic in runtime
21+
class Interpolation(Generic[_T]):
22+
value: _T
2323
expression: str
2424
conversion: Literal["a", "r", "s"] | None
2525
format_spec: str
2626

2727
__match_args__ = ("value", "expression", "conversion", "format_spec")
2828

2929
def __new__(
30-
cls, value: Any, expression: str = "", conversion: Literal["a", "r", "s"] | None = None, format_spec: str = ""
31-
) -> Interpolation: ...
30+
cls, value: _T, expression: str = "", conversion: Literal["a", "r", "s"] | None = None, format_spec: str = ""
31+
) -> Interpolation[_T]: ...
3232
def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ...
3333

3434
@overload

0 commit comments

Comments
 (0)