dbt-common 1.18__py3-none-any.whl → 1.20__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.
- dbt_common/__about__.py +1 -1
- dbt_common/clients/_jinja_blocks.py +20 -2
- dbt_common/clients/jinja.py +11 -2
- {dbt_common-1.18.dist-info → dbt_common-1.20.dist-info}/METADATA +1 -1
- {dbt_common-1.18.dist-info → dbt_common-1.20.dist-info}/RECORD +7 -7
- {dbt_common-1.18.dist-info → dbt_common-1.20.dist-info}/WHEEL +0 -0
- {dbt_common-1.18.dist-info → dbt_common-1.20.dist-info}/licenses/LICENSE +0 -0
dbt_common/__about__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
version = "1.
|
1
|
+
version = "1.20"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import dataclasses
|
2
2
|
import re
|
3
3
|
from collections import namedtuple
|
4
|
-
from typing import Dict, Iterator, List, Optional, Set, Union
|
4
|
+
from typing import Callable, Dict, Iterator, List, Optional, Set, Union
|
5
5
|
|
6
6
|
from dbt_common.exceptions import (
|
7
7
|
BlockDefinitionNotAtTopError,
|
@@ -115,6 +115,12 @@ class PositionedMatch:
|
|
115
115
|
match: Optional[re.Match]
|
116
116
|
|
117
117
|
|
118
|
+
@dataclasses.dataclass
|
119
|
+
class ExtractWarning:
|
120
|
+
warning_type: str
|
121
|
+
msg: str
|
122
|
+
|
123
|
+
|
118
124
|
class TagIterator:
|
119
125
|
def __init__(self, text: str) -> None:
|
120
126
|
self.text: str = text
|
@@ -326,8 +332,13 @@ _CONTROL_FLOW_END_TAGS = {v: k for k, v in _CONTROL_FLOW_TAGS.items()}
|
|
326
332
|
|
327
333
|
|
328
334
|
class BlockIterator:
|
329
|
-
def __init__(
|
335
|
+
def __init__(
|
336
|
+
self,
|
337
|
+
tag_iterator: TagIterator,
|
338
|
+
warning_callback: Optional[Callable[[ExtractWarning], None]] = None,
|
339
|
+
) -> None:
|
330
340
|
self.tag_parser = tag_iterator
|
341
|
+
self.warning_callback = warning_callback
|
331
342
|
self.current: Optional[Tag] = None
|
332
343
|
self.stack: List[str] = []
|
333
344
|
self.last_position: int = 0
|
@@ -393,6 +404,13 @@ class BlockIterator:
|
|
393
404
|
full_block=self.data[self.current.start : tag.end],
|
394
405
|
)
|
395
406
|
self.current = None
|
407
|
+
elif self.current is None and self.warning_callback:
|
408
|
+
# Warn on unexpected top-level tags
|
409
|
+
self.warning_callback(
|
410
|
+
ExtractWarning(
|
411
|
+
"unexpected_block", f"Found unexpected '{tag.block_type_name}' block tag."
|
412
|
+
)
|
413
|
+
)
|
396
414
|
|
397
415
|
if self.current:
|
398
416
|
linecount = self.data[: self.current.end].count("\n") + 1
|
dbt_common/clients/jinja.py
CHANGED
@@ -38,7 +38,13 @@ from dbt_common.utils.jinja import (
|
|
38
38
|
get_materialization_macro_name,
|
39
39
|
get_test_macro_name,
|
40
40
|
)
|
41
|
-
from dbt_common.clients._jinja_blocks import
|
41
|
+
from dbt_common.clients._jinja_blocks import (
|
42
|
+
BlockIterator,
|
43
|
+
BlockData,
|
44
|
+
BlockTag,
|
45
|
+
TagIterator,
|
46
|
+
ExtractWarning,
|
47
|
+
)
|
42
48
|
|
43
49
|
from dbt_common.exceptions import (
|
44
50
|
CompilationError,
|
@@ -659,6 +665,7 @@ def extract_toplevel_blocks(
|
|
659
665
|
text: str,
|
660
666
|
allowed_blocks: Optional[Set[str]] = None,
|
661
667
|
collect_raw_data: bool = True,
|
668
|
+
warning_callback: Optional[Callable[[ExtractWarning], None]] = None,
|
662
669
|
) -> List[Union[BlockData, BlockTag]]:
|
663
670
|
"""Extract the top-level blocks with matching block types from a jinja file.
|
664
671
|
|
@@ -672,6 +679,8 @@ def extract_toplevel_blocks(
|
|
672
679
|
be part of the results, as `BlockData` objects. They have a
|
673
680
|
`block_type_name` field of `'__dbt_data'` and will never have a
|
674
681
|
`block_name`.
|
682
|
+
:param warning_callback: An optional callback that will be called if there
|
683
|
+
are recoverable issues detected in the template.
|
675
684
|
:return: A list of `BlockTag`s matching the allowed block types and (if
|
676
685
|
`collect_raw_data` is `True`) `BlockData` objects.
|
677
686
|
"""
|
@@ -682,7 +691,7 @@ def extract_toplevel_blocks(
|
|
682
691
|
return _TESTING_BLOCKS_CACHE[hash]
|
683
692
|
|
684
693
|
tag_iterator = TagIterator(text)
|
685
|
-
blocks = BlockIterator(tag_iterator).lex_for_blocks(
|
694
|
+
blocks = BlockIterator(tag_iterator, warning_callback).lex_for_blocks(
|
686
695
|
allowed_blocks=allowed_blocks, collect_raw_data=collect_raw_data
|
687
696
|
)
|
688
697
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: dbt-common
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.20
|
4
4
|
Summary: The shared common utilities that dbt-core and adapter implementations use
|
5
5
|
Project-URL: Homepage, https://github.com/dbt-labs/dbt-common
|
6
6
|
Project-URL: Repository, https://github.com/dbt-labs/dbt-common.git
|
@@ -1,4 +1,4 @@
|
|
1
|
-
dbt_common/__about__.py,sha256=
|
1
|
+
dbt_common/__about__.py,sha256=SGYUg2wlOx0343f4ShHFemOkildSkKho2Xg2m7qLlg8,17
|
2
2
|
dbt_common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
3
|
dbt_common/behavior_flags.py,sha256=hQzxCqQSweJbRp_xoQqNnlUF77PBuOdCdLOSdcBlkxk,4885
|
4
4
|
dbt_common/constants.py,sha256=-Y5DIL1SDPQWtlCNizXRYxFgbx1D7LaLs1ysamvGMRk,278
|
@@ -12,9 +12,9 @@ dbt_common/semver.py,sha256=Znewz6tc_NBpXr4mZf20bK_RayPL4ODrnxDbkUZrrRo,15034
|
|
12
12
|
dbt_common/tests.py,sha256=6lC_JuRtoYO6cbAF8-R5aTM4HtQiM_EH8X5m_97duGY,315
|
13
13
|
dbt_common/ui.py,sha256=rc2TEM29raBFc_LXcg901pMDD07C2ohwp9qzkE-7pBY,2567
|
14
14
|
dbt_common/clients/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
15
|
-
dbt_common/clients/_jinja_blocks.py,sha256=
|
15
|
+
dbt_common/clients/_jinja_blocks.py,sha256=eUjZLBtLCASJRRj1G8b9u15A3PQMDCKvytIdWkTLSP4,15451
|
16
16
|
dbt_common/clients/agate_helper.py,sha256=anKKgKV5PSnFRuFeBwRMdHK3JCaQoUqB2ZXHD0su0Wo,9123
|
17
|
-
dbt_common/clients/jinja.py,sha256=
|
17
|
+
dbt_common/clients/jinja.py,sha256=wKwBCtIGKXOwU-KWWF2sz77nST-JUP26U_Zo_a6mNe8,22756
|
18
18
|
dbt_common/clients/system.py,sha256=aoUBtOuXVmkOyj6IhhJ3Y4a7JFzPO2F_zKyOtz3xy44,23932
|
19
19
|
dbt_common/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
20
20
|
dbt_common/contracts/constraints.py,sha256=_f1q3Rkcg2UwA7zI5XBbUMXnPUg6pw17UC7l1HyhyQM,1352
|
@@ -57,7 +57,7 @@ dbt_common/utils/encoding.py,sha256=6_kSY2FvGNYMg7oX7PrbvVioieydih3Kl7Ii802LaHI,
|
|
57
57
|
dbt_common/utils/executor.py,sha256=pNY0UbPlwQmTE69Vt_Rj91YGCIOEaqeYU3CjAds0T70,2454
|
58
58
|
dbt_common/utils/formatting.py,sha256=JUn5rzJ-uajs9wPCN0-f2iRFY1pOJF5YjTD9dERuLoc,165
|
59
59
|
dbt_common/utils/jinja.py,sha256=JXgNmJArGGy0h7qkbNLA3zaEQmoF1CxsNBYTlIwFXDw,1101
|
60
|
-
dbt_common-1.
|
61
|
-
dbt_common-1.
|
62
|
-
dbt_common-1.
|
63
|
-
dbt_common-1.
|
60
|
+
dbt_common-1.20.dist-info/METADATA,sha256=SM8vtxD3Hor76Ze62sZ2WjQlRpR-4smcG720v_a74XM,4944
|
61
|
+
dbt_common-1.20.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
62
|
+
dbt_common-1.20.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
63
|
+
dbt_common-1.20.dist-info/RECORD,,
|
File without changes
|
File without changes
|