Skip to content

Commit 1c16375

Browse files
committed
add comment explaining param incrementing, remove IntoTemplate
1 parent b934d15 commit 1c16375

1 file changed

Lines changed: 2 additions & 13 deletions

File tree

template.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
from typing import TYPE_CHECKING, Literal, NoReturn, Protocol, TypeVar, runtime_checkable
77

88
if TYPE_CHECKING:
9-
from collections.abc import Iterator, Sequence
9+
from collections.abc import Iterator
1010

1111
from typing_extensions import TypeIs
1212

1313
__all__ = [
1414
"CompiledSql",
1515
"IntoInterpolation",
16-
"IntoTemplate",
1716
"Param",
1817
"SupportsDuckdbTemplate",
1918
"param",
@@ -259,17 +258,6 @@ class IntoInterpolation(Protocol):
259258
format_spec: str
260259

261260

262-
@runtime_checkable
263-
class IntoTemplate(Protocol):
264-
"""Something that can be converted into string.templatelib.Template."""
265-
266-
strings: Sequence[str]
267-
interpolations: Sequence[IntoInterpolation]
268-
269-
def __iter__(self) -> Iterator[str | IntoInterpolation]:
270-
"""Iterate over the strings and interpolations in order."""
271-
272-
273261
def assert_param_name_legal(name: str) -> None:
274262
"""Eg `$param_1` is legal, but `$1param`, `$param-1`, `$param 1`, and `$p ; DROP TABLE users` are not."""
275263
# not implemented yet
@@ -387,6 +375,7 @@ def compile_parts(parts: Iterable[str | Param], /) -> CompiledSql:
387375
params_items = []
388376

389377
def next_name(suffix: str | None = None) -> str:
378+
# still count exact params in the count, so we get p0, my_param, p2, p3, my_param_2, p5, etc
390379
base = f"p{len(params_items)}"
391380
if suffix is not None:
392381
return f"{base}_{suffix}"

0 commit comments

Comments
 (0)