summaryrefslogtreecommitdiffstats
path: root/sqlglot/helper.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-02-08 05:38:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-02-08 05:38:42 +0000
commitc66e4a33e1a07c439f03fe47f146a6c6482bf6df (patch)
treecfdf01111c063b3e50841695e6c2768833aea4dc /sqlglot/helper.py
parentReleasing debian version 20.11.0-1. (diff)
downloadsqlglot-c66e4a33e1a07c439f03fe47f146a6c6482bf6df.tar.xz
sqlglot-c66e4a33e1a07c439f03fe47f146a6c6482bf6df.zip
Merging upstream version 21.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/helper.py')
-rw-r--r--sqlglot/helper.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/sqlglot/helper.py b/sqlglot/helper.py
index de737be..9799fe2 100644
--- a/sqlglot/helper.py
+++ b/sqlglot/helper.py
@@ -53,11 +53,13 @@ def seq_get(seq: t.Sequence[T], index: int) -> t.Optional[T]:
@t.overload
-def ensure_list(value: t.Collection[T]) -> t.List[T]: ...
+def ensure_list(value: t.Collection[T]) -> t.List[T]:
+ ...
@t.overload
-def ensure_list(value: T) -> t.List[T]: ...
+def ensure_list(value: T) -> t.List[T]:
+ ...
def ensure_list(value):
@@ -79,11 +81,13 @@ def ensure_list(value):
@t.overload
-def ensure_collection(value: t.Collection[T]) -> t.Collection[T]: ...
+def ensure_collection(value: t.Collection[T]) -> t.Collection[T]:
+ ...
@t.overload
-def ensure_collection(value: T) -> t.Collection[T]: ...
+def ensure_collection(value: T) -> t.Collection[T]:
+ ...
def ensure_collection(value):
@@ -232,7 +236,7 @@ def tsort(dag: t.Dict[T, t.Set[T]]) -> t.List[T]:
for node, deps in tuple(dag.items()):
for dep in deps:
- if not dep in dag:
+ if dep not in dag:
dag[dep] = set()
while dag:
@@ -316,6 +320,14 @@ def find_new_name(taken: t.Collection[str], base: str) -> str:
return new
+def is_int(text: str) -> bool:
+ try:
+ int(text)
+ return True
+ except ValueError:
+ return False
+
+
def name_sequence(prefix: str) -> t.Callable[[], str]:
"""Returns a name generator given a prefix (e.g. a0, a1, a2, ... if the prefix is "a")."""
sequence = count()