tinybird 5.0.4.dev0__py3-none-any.whl → 5.0.5.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tinybird/ch_utils/constants.py +1 -1
- tinybird/ch_utils/engine.py +5 -9
- tinybird/datafile/common.py +50 -74
- tinybird/feedback_manager.py +10 -110
- tinybird/git_settings.py +38 -118
- tinybird/prompts.py +1 -476
- tinybird/service_datasources.py +1 -1
- tinybird/sql.py +7 -5
- tinybird/sql_template.py +85 -68
- tinybird/sql_template_fmt.py +3 -2
- tinybird/sql_toolset.py +8 -8
- tinybird/tb/__cli__.py +2 -2
- tinybird/tb/client.py +73 -49
- tinybird/tb/modules/build.py +1 -1
- tinybird/tb/modules/build_common.py +1 -1
- tinybird/tb/modules/cli.py +15 -7
- tinybird/tb/modules/common.py +65 -45
- tinybird/tb/modules/config.py +1 -1
- tinybird/tb/modules/connection_kafka.py +6 -1
- tinybird/tb/modules/copy.py +1 -1
- tinybird/tb/modules/datafile/build.py +3 -3
- tinybird/tb/modules/datafile/build_common.py +2 -2
- tinybird/tb/modules/datafile/build_pipe.py +9 -7
- tinybird/tb/modules/datafile/diff.py +12 -10
- tinybird/tb/modules/datafile/format_common.py +1 -1
- tinybird/tb/modules/datafile/format_datasource.py +2 -2
- tinybird/tb/modules/datafile/format_pipe.py +3 -3
- tinybird/tb/modules/datafile/pull.py +1 -1
- tinybird/tb/modules/datasource.py +23 -15
- tinybird/tb/modules/deployment.py +8 -40
- tinybird/tb/modules/deployment_common.py +73 -17
- tinybird/tb/modules/deprecations.py +10 -8
- tinybird/tb/modules/endpoint.py +1 -1
- tinybird/tb/modules/feedback_manager.py +15 -7
- tinybird/tb/modules/fmt.py +1 -1
- tinybird/tb/modules/info.py +1 -1
- tinybird/tb/modules/infra.py +2 -2
- tinybird/tb/modules/llm_utils.py +7 -4
- tinybird/tb/modules/local.py +4 -2
- tinybird/tb/modules/local_common.py +6 -4
- tinybird/tb/modules/local_logs.py +5 -5
- tinybird/tb/modules/login_common.py +12 -6
- tinybird/tb/modules/materialization.py +1 -1
- tinybird/tb/modules/pipe.py +1 -1
- tinybird/tb/modules/preview.py +1 -0
- tinybird/tb/modules/project.py +0 -46
- tinybird/tb/modules/query_output.py +3 -1
- tinybird/tb/modules/secret.py +1 -1
- tinybird/tb/modules/sink.py +1 -1
- tinybird/tb/modules/table.py +14 -8
- tinybird/tb/modules/telemetry.py +7 -3
- tinybird/tb/modules/test.py +28 -2
- tinybird/tb/modules/test_common.py +62 -6
- tinybird/tb/modules/tinyunit/tinyunit.py +6 -6
- tinybird/tb/modules/token.py +23 -11
- tinybird/tb/modules/watch.py +5 -4
- tinybird/tb_cli_modules/common.py +74 -46
- tinybird/tb_cli_modules/config.py +1 -1
- tinybird/tb_cli_modules/telemetry.py +7 -3
- tinybird/tornado_template.py +99 -61
- {tinybird-5.0.4.dev0.dist-info → tinybird-5.0.5.dev0.dist-info}/METADATA +31 -2
- tinybird-5.0.5.dev0.dist-info/RECORD +104 -0
- tinybird/syncasync.py +0 -638
- tinybird-5.0.4.dev0.dist-info/RECORD +0 -105
- {tinybird-5.0.4.dev0.dist-info → tinybird-5.0.5.dev0.dist-info}/WHEEL +0 -0
- {tinybird-5.0.4.dev0.dist-info → tinybird-5.0.5.dev0.dist-info}/entry_points.txt +0 -0
- {tinybird-5.0.4.dev0.dist-info → tinybird-5.0.5.dev0.dist-info}/top_level.txt +0 -0
tinybird/ch_utils/constants.py
CHANGED
tinybird/ch_utils/engine.py
CHANGED
|
@@ -102,10 +102,6 @@ class TableDetails:
|
|
|
102
102
|
_engine_full = _engine_full.replace(" SETTINGS index_granularity = 8192", "")
|
|
103
103
|
return engine_replicated_to_local(_BACKQUOTED_ENGINE_NAME.sub(r"\1", _engine_full))
|
|
104
104
|
|
|
105
|
-
@property
|
|
106
|
-
def original_engine_full(self) -> Optional[str]:
|
|
107
|
-
return self.details.get("engine_full", None)
|
|
108
|
-
|
|
109
105
|
@property
|
|
110
106
|
def name(self) -> str:
|
|
111
107
|
return self.details.get("name", "")
|
|
@@ -305,10 +301,10 @@ class EngineOption:
|
|
|
305
301
|
name: str,
|
|
306
302
|
sql: str,
|
|
307
303
|
required: Optional[bool] = None,
|
|
308
|
-
default_value=None,
|
|
304
|
+
default_value: Optional[str] = None,
|
|
309
305
|
is_valid: Optional[Callable[[List[Dict[str, Any]], str], Optional[str]]] = None,
|
|
310
306
|
tb_param: Optional[str] = None,
|
|
311
|
-
):
|
|
307
|
+
) -> None:
|
|
312
308
|
self.name = name
|
|
313
309
|
self.sql = sql
|
|
314
310
|
self.required = required
|
|
@@ -322,10 +318,10 @@ class EngineParam:
|
|
|
322
318
|
self,
|
|
323
319
|
name: str,
|
|
324
320
|
required: Optional[bool] = None,
|
|
325
|
-
default_value=None,
|
|
321
|
+
default_value: Optional[str] = None,
|
|
326
322
|
is_valid: Optional[Callable[[List[Dict[str, Any]], str], Optional[str]]] = None,
|
|
327
323
|
tb_param: Optional[str] = None,
|
|
328
|
-
):
|
|
324
|
+
) -> None:
|
|
329
325
|
self.name = name
|
|
330
326
|
self.required = required
|
|
331
327
|
self.default_value = default_value
|
|
@@ -360,7 +356,7 @@ def columns_are_valid(columns: List[Dict[str, Any]], column_names: str) -> str:
|
|
|
360
356
|
return ", ".join(new_column_names)
|
|
361
357
|
|
|
362
358
|
|
|
363
|
-
def sorting_key_is_valid(columns: List[Dict[str, Any]], value: Optional[str]) -> str:
|
|
359
|
+
def sorting_key_is_valid(columns: List[Dict[str, Any]], value: Optional[str]) -> str: # noqa: ARG001
|
|
364
360
|
INVALID_SORTING_KEYS = ["tuple()"]
|
|
365
361
|
|
|
366
362
|
if not value:
|
tinybird/datafile/common.py
CHANGED
|
@@ -12,13 +12,12 @@ import shlex
|
|
|
12
12
|
import string
|
|
13
13
|
import textwrap
|
|
14
14
|
import traceback
|
|
15
|
-
from collections import namedtuple
|
|
16
15
|
from dataclasses import dataclass
|
|
17
16
|
from enum import Enum
|
|
18
17
|
from io import StringIO
|
|
19
18
|
from pathlib import Path
|
|
20
19
|
from string import Template
|
|
21
|
-
from typing import Any, Callable, Dict, Iterable, List, Literal, NamedTuple, Optional, Tuple, cast
|
|
20
|
+
from typing import Any, Callable, Dict, Iterable, Iterator, List, Literal, NamedTuple, Optional, Tuple, TypeVar, cast
|
|
22
21
|
|
|
23
22
|
import click
|
|
24
23
|
from croniter import croniter
|
|
@@ -35,6 +34,8 @@ from tinybird.utils.bools import parse_optional_bool
|
|
|
35
34
|
# from tinybird.sql import parse_indexes_structure, parse_table_structure, schema_to_sql_columns
|
|
36
35
|
|
|
37
36
|
# Pre-compiled regex patterns
|
|
37
|
+
T = TypeVar("T")
|
|
38
|
+
|
|
38
39
|
_PATTERN_INDEX_ENTRY = re.compile(
|
|
39
40
|
r"(\w+)\s+([\w\s*\[\]\*\(\),\'\"-><.]+)\s+TYPE\s+(\w+)(?:\(([\w\s*.,]+)\))?(?:\s+GRANULARITY\s+(\d+))?"
|
|
40
41
|
)
|
|
@@ -137,8 +138,6 @@ VISIBLE_PIPE_NODE_TYPES = {
|
|
|
137
138
|
class DataFileExtensions:
|
|
138
139
|
PIPE = ".pipe"
|
|
139
140
|
DATASOURCE = ".datasource"
|
|
140
|
-
INCL = ".incl"
|
|
141
|
-
CONNECTION = ".connection"
|
|
142
141
|
|
|
143
142
|
|
|
144
143
|
class CopyModes:
|
|
@@ -148,7 +147,7 @@ class CopyModes:
|
|
|
148
147
|
valid_modes = (APPEND, REPLACE)
|
|
149
148
|
|
|
150
149
|
@staticmethod
|
|
151
|
-
def is_valid(node_mode):
|
|
150
|
+
def is_valid(node_mode: str) -> bool:
|
|
152
151
|
return node_mode.lower() in CopyModes.valid_modes
|
|
153
152
|
|
|
154
153
|
|
|
@@ -178,7 +177,6 @@ class PipeParameters(Parameters):
|
|
|
178
177
|
class CopyParameters(Parameters):
|
|
179
178
|
TARGET_DATASOURCE = "target_datasource"
|
|
180
179
|
COPY_SCHEDULE = "copy_schedule"
|
|
181
|
-
COPY_MODE = "copy_mode"
|
|
182
180
|
COPY_MODE_ALIAS = "mode" # we need this because bot MODE and COPY_MODE go to `mode` variable inside the node
|
|
183
181
|
ON_DEMAND_COMPUTE = "on_demand_compute"
|
|
184
182
|
MANDATORY_ATTRIBUTES = PipeParameters.MANDATORY_ATTRIBUTES.union({TARGET_DATASOURCE})
|
|
@@ -197,7 +195,6 @@ class SinkParameters(Parameters):
|
|
|
197
195
|
KAFKA_MANDATORY_ATTRIBUTES = PipeParameters.MANDATORY_ATTRIBUTES.union(
|
|
198
196
|
{"export_connection_name", "export_kafka_topic", "export_schedule"}
|
|
199
197
|
)
|
|
200
|
-
KAFKA_ACCEPTED_ATTRIBUTES = PipeParameters.ACCEPTED_ATTRIBUTES.union(KAFKA_MANDATORY_ATTRIBUTES)
|
|
201
198
|
|
|
202
199
|
# For S3/GCS sinks
|
|
203
200
|
BLOB_MANDATORY_ATTRIBUTES = PipeParameters.MANDATORY_ATTRIBUTES.union(
|
|
@@ -384,12 +381,6 @@ class Datafile:
|
|
|
384
381
|
self.filtering_tags: Optional[List[str]] = None
|
|
385
382
|
self.kind: Optional[DatafileKind] = None
|
|
386
383
|
|
|
387
|
-
def is_equal(self, other):
|
|
388
|
-
if len(self.nodes) != len(other.nodes):
|
|
389
|
-
return False
|
|
390
|
-
|
|
391
|
-
return all(self.nodes[i] == other.nodes[i] for i, _ in enumerate(self.nodes))
|
|
392
|
-
|
|
393
384
|
def set_kind(self, kind: DatafileKind):
|
|
394
385
|
self.kind = kind
|
|
395
386
|
|
|
@@ -655,7 +646,8 @@ class Datafile:
|
|
|
655
646
|
engine_args = engine_info.get("args", [])
|
|
656
647
|
for arg_name, arg_value in engine_args:
|
|
657
648
|
if arg_name == "ver":
|
|
658
|
-
|
|
649
|
+
ver_column: str = arg_value
|
|
650
|
+
return ver_column
|
|
659
651
|
|
|
660
652
|
return None
|
|
661
653
|
|
|
@@ -814,18 +806,6 @@ class TableIndex:
|
|
|
814
806
|
def to_sql(self):
|
|
815
807
|
return f"INDEX {self.to_datafile()}"
|
|
816
808
|
|
|
817
|
-
def add_index_sql(self):
|
|
818
|
-
return f"ADD {self.to_sql()}"
|
|
819
|
-
|
|
820
|
-
def drop_index_sql(self):
|
|
821
|
-
return f"DROP INDEX IF EXISTS {self.name}"
|
|
822
|
-
|
|
823
|
-
def materialize_index_sql(self):
|
|
824
|
-
return f"MATERIALIZE INDEX IF EXISTS {self.name}"
|
|
825
|
-
|
|
826
|
-
def clear_index_sql(self):
|
|
827
|
-
return f"CLEAR INDEX IF EXISTS {self.name}"
|
|
828
|
-
|
|
829
809
|
|
|
830
810
|
def parse_indexes_structure(indexes: Optional[List[str]]) -> List[TableIndex]:
|
|
831
811
|
"""
|
|
@@ -977,7 +957,10 @@ def clean_comments_rstrip_keep_empty_lines(schema_to_clean: Optional[str]) -> st
|
|
|
977
957
|
return cleaned_schema.rstrip()
|
|
978
958
|
|
|
979
959
|
|
|
980
|
-
SyntaxExpr
|
|
960
|
+
class SyntaxExpr(NamedTuple):
|
|
961
|
+
name: str
|
|
962
|
+
regex: re.Pattern[str]
|
|
963
|
+
|
|
981
964
|
|
|
982
965
|
NULL = SyntaxExpr("NULL", re.compile(r"\s+NULL([^a-z0-9_]|$)", re.IGNORECASE))
|
|
983
966
|
NOTNULL = SyntaxExpr("NOTNULL", re.compile(r"\s+NOT\s+NULL([^a-z0-9_]|$)", re.IGNORECASE))
|
|
@@ -1196,10 +1179,9 @@ def _parse_table_structure(schema: str) -> List[Dict[str, Any]]:
|
|
|
1196
1179
|
jsonpath: str = ""
|
|
1197
1180
|
last: Optional[SyntaxExpr] = None
|
|
1198
1181
|
col_start: Tuple[int, int] = (0, 0) # (0, 0) means not set. It's not a valid line/pos as they start at 1
|
|
1199
|
-
col_end: Tuple[int, int] = (0, 0) # (0, 0) means not set. It's not a valid line/pos as they start at 1
|
|
1200
1182
|
|
|
1201
|
-
def add_column(found: str) -> None:
|
|
1202
|
-
nonlocal name, _type, default, codec, jsonpath, col_start
|
|
1183
|
+
def add_column(found: str) -> None: # noqa: ARG001
|
|
1184
|
+
nonlocal name, _type, default, codec, jsonpath, col_start
|
|
1203
1185
|
lineno, pos = col_start
|
|
1204
1186
|
default = "" if not default else f"DEFAULT {default}"
|
|
1205
1187
|
codec = "" if not codec else f"CODEC{codec}"
|
|
@@ -1217,7 +1199,6 @@ def _parse_table_structure(schema: str) -> List[Dict[str, Any]]:
|
|
|
1217
1199
|
"default_value": default,
|
|
1218
1200
|
"jsonpath": jsonpath,
|
|
1219
1201
|
# "col_start": col_start,
|
|
1220
|
-
# "col_end": col_end,
|
|
1221
1202
|
}
|
|
1222
1203
|
)
|
|
1223
1204
|
name = ""
|
|
@@ -1380,7 +1361,6 @@ def _parse_table_structure(schema: str) -> List[Dict[str, Any]]:
|
|
|
1380
1361
|
elif found == COMMA:
|
|
1381
1362
|
advance(",")
|
|
1382
1363
|
valid_next = []
|
|
1383
|
-
col_end = (line, pos)
|
|
1384
1364
|
add_column("COMMA")
|
|
1385
1365
|
elif found == NEW_LINE:
|
|
1386
1366
|
i += 1
|
|
@@ -1396,7 +1376,6 @@ def _parse_table_structure(schema: str) -> List[Dict[str, Any]]:
|
|
|
1396
1376
|
)
|
|
1397
1377
|
)
|
|
1398
1378
|
last = found
|
|
1399
|
-
col_end = (line, i + 1)
|
|
1400
1379
|
# Only add the last column if we've parsed something. This allows for a trailing comma after the last column.
|
|
1401
1380
|
if name:
|
|
1402
1381
|
add_column("EOF")
|
|
@@ -1649,13 +1628,15 @@ def parse(
|
|
|
1649
1628
|
doc.set_kind(kind)
|
|
1650
1629
|
doc.raw = list(StringIO(s, newline=None))
|
|
1651
1630
|
|
|
1652
|
-
parser_state
|
|
1653
|
-
|
|
1654
|
-
|
|
1631
|
+
class parser_state(NamedTuple):
|
|
1632
|
+
multiline: bool
|
|
1633
|
+
current_node: Any # False until a node dict is assigned
|
|
1634
|
+
command: str
|
|
1635
|
+
start_lineno: int
|
|
1655
1636
|
|
|
1656
1637
|
parser_state.multiline = False
|
|
1657
1638
|
parser_state.current_node = False
|
|
1658
|
-
parser_state.start_lineno =
|
|
1639
|
+
parser_state.start_lineno = 0
|
|
1659
1640
|
|
|
1660
1641
|
def multiline_not_supported(func: Callable[..., Any]) -> Callable[..., Any]:
|
|
1661
1642
|
@functools.wraps(func)
|
|
@@ -1676,7 +1657,7 @@ def parse(
|
|
|
1676
1657
|
def deprecated(severity: Literal["error", "warning"]) -> Callable[..., Any]:
|
|
1677
1658
|
def inner(func: Callable[..., Any]) -> Callable[..., Any]:
|
|
1678
1659
|
@functools.wraps(func)
|
|
1679
|
-
def raise_deprecation_error(*args: Any, **kwargs: Any) -> Any:
|
|
1660
|
+
def raise_deprecation_error(*args: Any, **kwargs: Any) -> Any: # noqa: ARG001
|
|
1680
1661
|
raise DatafileSyntaxError(
|
|
1681
1662
|
f"{kwargs['cmd'].upper()} has been deprecated",
|
|
1682
1663
|
lineno=kwargs["lineno"],
|
|
@@ -1684,7 +1665,7 @@ def parse(
|
|
|
1684
1665
|
)
|
|
1685
1666
|
|
|
1686
1667
|
@functools.wraps(func)
|
|
1687
|
-
def add_deprecation_warning(*args: Any, **kwargs: Any) -> Any:
|
|
1668
|
+
def add_deprecation_warning(*args: Any, **kwargs: Any) -> Any: # noqa: ARG001
|
|
1688
1669
|
warnings.append(
|
|
1689
1670
|
DatafileParseWarning(
|
|
1690
1671
|
message=f"{kwargs['cmd'].upper()} has been deprecated and will be ignored.",
|
|
@@ -1702,7 +1683,7 @@ def parse(
|
|
|
1702
1683
|
def not_supported_yet(extra_message: str = "") -> Callable[..., Any]:
|
|
1703
1684
|
def inner(func: Callable[..., Any]) -> Callable[..., Any]:
|
|
1704
1685
|
@functools.wraps(func)
|
|
1705
|
-
def raise_not_supported_yet_error(*args: Any, **kwargs: Any) -> Any:
|
|
1686
|
+
def raise_not_supported_yet_error(*args: Any, **kwargs: Any) -> Any: # noqa: ARG001
|
|
1706
1687
|
extra_message_bit = f". {extra_message}" if extra_message else ""
|
|
1707
1688
|
raise DatafileSyntaxError(
|
|
1708
1689
|
f"{kwargs['cmd']} is not supported yet{extra_message_bit}",
|
|
@@ -1714,14 +1695,14 @@ def parse(
|
|
|
1714
1695
|
|
|
1715
1696
|
return inner
|
|
1716
1697
|
|
|
1717
|
-
def assign(attr):
|
|
1698
|
+
def assign(attr: str) -> Callable[..., None]:
|
|
1718
1699
|
@multiline_not_supported
|
|
1719
|
-
def _fn(x, **kwargs):
|
|
1700
|
+
def _fn(x: str, **kwargs: Any) -> None: # noqa: ARG001
|
|
1720
1701
|
setattr(doc, attr, _unquote(x))
|
|
1721
1702
|
|
|
1722
1703
|
return _fn
|
|
1723
1704
|
|
|
1724
|
-
def schema(*args, **kwargs):
|
|
1705
|
+
def schema(*args: str, **kwargs: Any) -> None:
|
|
1725
1706
|
s = _unquote("".join(args))
|
|
1726
1707
|
try:
|
|
1727
1708
|
sh = parse_table_structure(s)
|
|
@@ -1734,7 +1715,7 @@ def parse(
|
|
|
1734
1715
|
parser_state.current_node["schema"] = ",".join(schema_to_sql_columns(sh))
|
|
1735
1716
|
parser_state.current_node["columns"] = sh
|
|
1736
1717
|
|
|
1737
|
-
def indexes(*args, **kwargs):
|
|
1718
|
+
def indexes(*args: str, **kwargs: Any) -> None:
|
|
1738
1719
|
s = _unquote("".join(args))
|
|
1739
1720
|
if not s:
|
|
1740
1721
|
return
|
|
@@ -1770,7 +1751,7 @@ def parse(
|
|
|
1770
1751
|
|
|
1771
1752
|
def assign_var_json(v: str) -> Callable[[VarArg(str), KwArg(Any)], None]:
|
|
1772
1753
|
@multiline_not_supported
|
|
1773
|
-
def _f(*args: str, **kwargs: Any):
|
|
1754
|
+
def _f(*args: str, **kwargs: Any) -> None: # noqa: ARG001
|
|
1774
1755
|
s = _unquote((" ".join(args)).strip())
|
|
1775
1756
|
tmp = eval_var(s, skip=skip_eval)
|
|
1776
1757
|
# When skip_eval is True and the value contains an unrendered template,
|
|
@@ -1783,28 +1764,28 @@ def parse(
|
|
|
1783
1764
|
|
|
1784
1765
|
return _f
|
|
1785
1766
|
|
|
1786
|
-
def kafka_key_avro_deserialization_deprecated(*args: str, **kwargs: Any):
|
|
1767
|
+
def kafka_key_avro_deserialization_deprecated(*args: str, **kwargs: Any) -> None: # noqa: ARG001
|
|
1787
1768
|
raise DatafileSyntaxError(
|
|
1788
1769
|
f'{kwargs["cmd"].upper()} has been deprecated. Use "KAFKA_KEY_FORMAT avro" in the corresponding .datasource file instead',
|
|
1789
1770
|
lineno=kwargs["lineno"],
|
|
1790
1771
|
pos=1,
|
|
1791
1772
|
)
|
|
1792
1773
|
|
|
1793
|
-
def kafka_target_partitions_deprecated(*args: str, **kwargs: Any):
|
|
1774
|
+
def kafka_target_partitions_deprecated(*args: str, **kwargs: Any) -> None: # noqa: ARG001
|
|
1794
1775
|
warnings.append(
|
|
1795
1776
|
DatafileParseWarning(
|
|
1796
1777
|
message=f"{kwargs['cmd'].upper()} has been deprecated and will be ignored.",
|
|
1797
1778
|
)
|
|
1798
1779
|
)
|
|
1799
1780
|
|
|
1800
|
-
def import_external_datasource_deprecated(*args: str, **kwargs: Any):
|
|
1781
|
+
def import_external_datasource_deprecated(*args: str, **kwargs: Any) -> None: # noqa: ARG001
|
|
1801
1782
|
warnings.append(
|
|
1802
1783
|
DatafileParseWarning(
|
|
1803
1784
|
message=f"{kwargs['cmd'].upper()} has been deprecated and will be ignored.",
|
|
1804
1785
|
)
|
|
1805
1786
|
)
|
|
1806
1787
|
|
|
1807
|
-
def import_service_deprecated(*args: str, **kwargs: Any):
|
|
1788
|
+
def import_service_deprecated(*args: str, **kwargs: Any) -> None: # noqa: ARG001
|
|
1808
1789
|
warnings.append(
|
|
1809
1790
|
DatafileParseWarning(
|
|
1810
1791
|
message=(
|
|
@@ -1814,7 +1795,7 @@ def parse(
|
|
|
1814
1795
|
)
|
|
1815
1796
|
)
|
|
1816
1797
|
|
|
1817
|
-
def import_strategy_deprecated(*args: str, **kwargs: Any):
|
|
1798
|
+
def import_strategy_deprecated(*args: str, **kwargs: Any) -> None: # noqa: ARG001
|
|
1818
1799
|
raise DatafileSyntaxError(
|
|
1819
1800
|
(
|
|
1820
1801
|
f"{kwargs['cmd'].upper()} has been deprecated. The built-in default is 'append'. "
|
|
@@ -1824,14 +1805,14 @@ def parse(
|
|
|
1824
1805
|
pos=1,
|
|
1825
1806
|
)
|
|
1826
1807
|
|
|
1827
|
-
def kafka_store_binary_headers_deprecated(*args: str, **kwargs: Any):
|
|
1808
|
+
def kafka_store_binary_headers_deprecated(*args: str, **kwargs: Any) -> None: # noqa: ARG001
|
|
1828
1809
|
raise DatafileSyntaxError(
|
|
1829
1810
|
f"{kwargs['cmd'].upper()} has been deprecated. When KAFKA_STORE_HEADERS is True, __headers is always of type Map(String, String)",
|
|
1830
1811
|
lineno=kwargs["lineno"],
|
|
1831
1812
|
pos=1,
|
|
1832
1813
|
)
|
|
1833
1814
|
|
|
1834
|
-
def export_service(*args: str, **kwargs: Any):
|
|
1815
|
+
def export_service(*args: str, **kwargs: Any) -> None: # noqa: ARG001
|
|
1835
1816
|
warnings.append(
|
|
1836
1817
|
DatafileParseWarning(
|
|
1837
1818
|
message=(
|
|
@@ -1846,18 +1827,18 @@ def parse(
|
|
|
1846
1827
|
pass # Deprecated
|
|
1847
1828
|
|
|
1848
1829
|
@multiline_not_supported
|
|
1849
|
-
def node(*args: str, **kwargs: Any) -> None:
|
|
1830
|
+
def node(*args: str, **kwargs: Any) -> None: # noqa: ARG001
|
|
1850
1831
|
node = {"name": eval_var(_unquote(args[0]))}
|
|
1851
1832
|
doc.nodes.append(node)
|
|
1852
1833
|
parser_state.current_node = node
|
|
1853
1834
|
|
|
1854
1835
|
@multiline_not_supported
|
|
1855
|
-
def scope(*args: str, **kwargs: Any) -> None:
|
|
1836
|
+
def scope(*args: str, **kwargs: Any) -> None: # noqa: ARG001
|
|
1856
1837
|
scope = {"name": eval_var(_unquote(args[0]))}
|
|
1857
1838
|
doc.nodes.append(scope)
|
|
1858
1839
|
parser_state.current_node = scope
|
|
1859
1840
|
|
|
1860
|
-
def description(*args: str, **kwargs: Any) -> None:
|
|
1841
|
+
def description(*args: str, **kwargs: Any) -> None: # noqa: ARG001
|
|
1861
1842
|
description = (" ".join(args)).strip()
|
|
1862
1843
|
|
|
1863
1844
|
if parser_state.current_node:
|
|
@@ -1867,13 +1848,13 @@ def parse(
|
|
|
1867
1848
|
else:
|
|
1868
1849
|
doc.description = description
|
|
1869
1850
|
|
|
1870
|
-
def kafka_ssl_ca_pem(*args: str, **kwargs: Any) -> None:
|
|
1851
|
+
def kafka_ssl_ca_pem(*args: str, **kwargs: Any) -> None: # noqa: ARG001
|
|
1871
1852
|
kafka_ssl_ca_pem = ("\n".join(args)).strip()
|
|
1872
1853
|
parser_state.current_node["kafka_ssl_ca_pem"] = kafka_ssl_ca_pem
|
|
1873
1854
|
|
|
1874
|
-
def sql(var_name: str, **kwargs: Any) -> Callable[[str, KwArg(Any)], None]:
|
|
1855
|
+
def sql(var_name: str, **kwargs: Any) -> Callable[[str, KwArg(Any)], None]: # noqa: ARG001
|
|
1875
1856
|
# TODO(eclbg): We shouldn't allow SQL in datasource files
|
|
1876
|
-
def _f(sql: str, *args: Any, **kwargs: Any) -> None:
|
|
1857
|
+
def _f(sql: str, *args: Any, **kwargs: Any) -> None: # noqa: ARG001
|
|
1877
1858
|
if not parser_state.multiline:
|
|
1878
1859
|
raise DatafileSyntaxError(
|
|
1879
1860
|
"SQL must be multiline",
|
|
@@ -2016,13 +1997,13 @@ def parse(
|
|
|
2016
1997
|
if "engine" not in parser_state.current_node:
|
|
2017
1998
|
parser_state.current_node["engine"] = {"type": None, "args": []}
|
|
2018
1999
|
|
|
2019
|
-
def set_engine(*args: str, **kwargs: Any) -> None:
|
|
2000
|
+
def set_engine(*args: str, **kwargs: Any) -> None: # noqa: ARG001
|
|
2020
2001
|
__init_engine("ENGINE")
|
|
2021
2002
|
engine_type = _unquote((" ".join(args)).strip())
|
|
2022
2003
|
parser_state.current_node["engine"]["type"] = eval_var(engine_type, skip=skip_eval)
|
|
2023
2004
|
|
|
2024
2005
|
def add_engine_var(v: str) -> Callable[[VarArg(str), KwArg(Any)], None]:
|
|
2025
|
-
def _f(*args: str, **kwargs: Any):
|
|
2006
|
+
def _f(*args: str, **kwargs: Any) -> None: # noqa: ARG001
|
|
2026
2007
|
__init_engine(f"ENGINE_{v}".upper())
|
|
2027
2008
|
engine_arg = eval_var(_unquote((" ".join(args)).strip()), skip=skip_eval)
|
|
2028
2009
|
if v.lower() == "ttl" and not engine_arg:
|
|
@@ -2167,6 +2148,7 @@ def parse(
|
|
|
2167
2148
|
|
|
2168
2149
|
cmds = cmds_per_datafile_kind[kind]
|
|
2169
2150
|
|
|
2151
|
+
multiline_lines: List[str] = []
|
|
2170
2152
|
lineno = 1
|
|
2171
2153
|
try:
|
|
2172
2154
|
while lineno <= len(lines):
|
|
@@ -2189,7 +2171,7 @@ def parse(
|
|
|
2189
2171
|
cmd, args = lexer[0], lexer[1:]
|
|
2190
2172
|
if parser_state.multiline and cmd.lower() in cmds and not line.startswith((" ", "\t")):
|
|
2191
2173
|
cmds[parser_state.command](
|
|
2192
|
-
|
|
2174
|
+
"".join(multiline_lines),
|
|
2193
2175
|
lineno=lineno,
|
|
2194
2176
|
replace_includes=replace_includes,
|
|
2195
2177
|
cmd=parser_state.command,
|
|
@@ -2201,7 +2183,7 @@ def parse(
|
|
|
2201
2183
|
parser_state.multiline = True
|
|
2202
2184
|
parser_state.command = cmd.lower()
|
|
2203
2185
|
parser_state.start_lineno = lineno
|
|
2204
|
-
|
|
2186
|
+
multiline_lines.clear()
|
|
2205
2187
|
else:
|
|
2206
2188
|
if cmd.lower() == "settings":
|
|
2207
2189
|
msg = (
|
|
@@ -2227,12 +2209,12 @@ def parse(
|
|
|
2227
2209
|
pos=0,
|
|
2228
2210
|
)
|
|
2229
2211
|
else:
|
|
2230
|
-
|
|
2212
|
+
multiline_lines.append(line)
|
|
2231
2213
|
lineno += 1
|
|
2232
2214
|
# close final state
|
|
2233
2215
|
if parser_state.multiline:
|
|
2234
2216
|
cmds[parser_state.command](
|
|
2235
|
-
|
|
2217
|
+
"".join(multiline_lines),
|
|
2236
2218
|
lineno=lineno,
|
|
2237
2219
|
replace_includes=replace_includes,
|
|
2238
2220
|
cmd=parser_state.command,
|
|
@@ -2296,7 +2278,7 @@ class ImportReplacements:
|
|
|
2296
2278
|
return None, None
|
|
2297
2279
|
|
|
2298
2280
|
@staticmethod
|
|
2299
|
-
def get_datafile_param_for_linker_param(
|
|
2281
|
+
def get_datafile_param_for_linker_param(linker_param: str) -> Optional[str]:
|
|
2300
2282
|
"""Returns the datafile parameter name for a given linter parameter."""
|
|
2301
2283
|
linker_param = linker_param.lower()
|
|
2302
2284
|
for datafile_k, linker_k, _ in ImportReplacements._REPLACEMENTS:
|
|
@@ -2387,7 +2369,7 @@ class ExportReplacements:
|
|
|
2387
2369
|
return None
|
|
2388
2370
|
|
|
2389
2371
|
|
|
2390
|
-
def get_project_filenames(folder: str, with_vendor=False) -> List[str]:
|
|
2372
|
+
def get_project_filenames(folder: str, with_vendor: bool = False) -> List[str]:
|
|
2391
2373
|
folders: List[str] = [
|
|
2392
2374
|
f"{folder}/*.datasource",
|
|
2393
2375
|
f"{folder}/datasources/*.datasource",
|
|
@@ -2409,17 +2391,11 @@ def get_project_filenames(folder: str, with_vendor=False) -> List[str]:
|
|
|
2409
2391
|
return filenames
|
|
2410
2392
|
|
|
2411
2393
|
|
|
2412
|
-
def
|
|
2413
|
-
folder = folder or "."
|
|
2414
|
-
filenames = get_project_filenames(folder)
|
|
2415
|
-
return any(f for f in filenames if "spans" in str(f) and "vendor" not in str(f))
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
def peek(iterable):
|
|
2394
|
+
def peek(iterable: Iterator[T]) -> Tuple[Optional[T], Iterator[T]]:
|
|
2419
2395
|
try:
|
|
2420
2396
|
first = next(iterable)
|
|
2421
2397
|
except Exception:
|
|
2422
|
-
return None,
|
|
2398
|
+
return None, iter(())
|
|
2423
2399
|
return first, itertools.chain([first], iterable)
|
|
2424
2400
|
|
|
2425
2401
|
|