Skip to content

Commit 3963c2e

Browse files
committed
Update docstubs stubs for preview
1 parent 24d56dd commit 3963c2e

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

stubs/micropython-v1_28_0_preview-docstubs/modules.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"firmware": "micropython-v1_28_0_preview",
99
"nodename": "micropython",
1010
"version": "v1.28.0-preview",
11-
"release": "v1.28.0-preview-241-g2322d37a9",
11+
"release": "v1.28.0-preview-250-g68c2d4e45",
1212
"sysname": "micropython"
1313
},
1414
"stubber": {
@@ -368,6 +368,10 @@
368368
"file": "stm/__init__.pyi",
369369
"module": "__init__"
370370
},
371+
{
372+
"file": "string/templatelib.pyi",
373+
"module": "templatelib"
374+
},
371375
{
372376
"file": "struct/__init__.pyi",
373377
"module": "__init__"
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
"""
2+
PEP 750 template string support.
3+
4+
MicroPython module: https://docs.micropython.org/en/v1.28.0/library/string.templatelib.html
5+
6+
This module provides support for template strings (t-strings) as defined in
7+
`PEP 750 <https://peps.python.org/pep-0750/>`_. Template strings are created
8+
using the ``t`` prefix and provide access to both the literal string parts and
9+
interpolated values before they are combined.
10+
11+
**Availability:** template strings require ``MICROPY_PY_TSTRINGS`` to be enabled
12+
at compile time. They are enabled by default at the full feature level, which
13+
includes the alif, mimxrt and samd (SAMD51 only) ports, the unix coverage variant
14+
and the webassembly pyscript variant.
15+
"""
16+
17+
# source version: v1.28.0-preview
18+
# origin module:: repos/micropython/docs/library/string.templatelib.rst
19+
from __future__ import annotations
20+
from _typeshed import Incomplete
21+
from typing_extensions import TypeVar, TypeAlias, Awaitable
22+
23+
class Template:
24+
"""
25+
Represents a template string. Template objects are typically created by
26+
t-string syntax (``t"..."``) but can also be constructed directly using
27+
the constructor.
28+
"""
29+
def __init__(self, *args) -> None: ...
30+
def __iter__(self) -> Incomplete:
31+
"""
32+
Iterate over the template contents, yielding string parts and
33+
:class:`Interpolation` objects in the order they appear. Empty strings
34+
are omitted.
35+
"""
36+
...
37+
def __add__(self, other) -> Incomplete:
38+
"""
39+
Concatenate two templates. Returns a new :class:`Template` combining
40+
the strings and interpolations from both templates.
41+
42+
:raises TypeError: if *other* is not a :class:`Template`
43+
44+
Template concatenation with ``str`` is prohibited to avoid ambiguity
45+
about whether the string should be treated as a literal or interpolation::
46+
47+
t1 = t"Hello "
48+
t2 = t"World"
49+
result = t1 + t2 # Valid
50+
51+
# TypeError: cannot concatenate str to Template
52+
result = t1 + "World"
53+
"""
54+
...
55+
56+
class Interpolation:
57+
"""
58+
Represents an interpolated expression within a template string. All
59+
arguments can be passed as keyword arguments.
60+
"""
61+
def __init__(self, value, expression="", conversion=None, format_spec="") -> None: ...

0 commit comments

Comments
 (0)