dbt-common 1.11.0__py3-none-any.whl → 1.13.0__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 CHANGED
@@ -1 +1 @@
1
- version = "1.11.0"
1
+ version = "1.13.0"
@@ -139,4 +139,4 @@ class Behavior:
139
139
  for flag in self._flags:
140
140
  if flag.name == name:
141
141
  return flag
142
- raise CompilationError(f"The flag {name} has not be registered.")
142
+ raise CompilationError(f"The flag {name} has not been registered.")
@@ -1,6 +1,7 @@
1
+ import dataclasses
1
2
  import re
2
3
  from collections import namedtuple
3
- from typing import Iterator, List, Optional, Set, Union
4
+ from typing import Dict, Iterator, List, Optional, Set, Union
4
5
 
5
6
  from dbt_common.exceptions import (
6
7
  BlockDefinitionNotAtTopError,
@@ -104,11 +105,25 @@ STRING_PATTERN = regex(r"(?P<string>('([^'\\]*(?:\\.[^'\\]*)*)'|" r'"([^"\\]*(?:
104
105
  QUOTE_START_PATTERN = regex(r"""(?P<quote>(['"]))""")
105
106
 
106
107
 
108
+ @dataclasses.dataclass
109
+ class PositionedMatch:
110
+ """This class is used to cache search information, accelerating TagIterator.
111
+ It records the result of searching a string from the start_pos and also
112
+ the position of the first match, or None if there is no match."""
113
+
114
+ start_pos: int
115
+ match: Optional[re.Match]
116
+
117
+
107
118
  class TagIterator:
108
119
  def __init__(self, text: str) -> None:
109
120
  self.text: str = text
110
121
  self.pos: int = 0
111
122
 
123
+ # A cache of the most recent matches seen for each pattern, maintained
124
+ # in order to avoid slowly re-searching long inputs many times.
125
+ self._past_matches: Dict[re.Pattern, PositionedMatch] = {}
126
+
112
127
  def linepos(self, end: Optional[int] = None) -> str:
113
128
  """Return relative position in line.
114
129
 
@@ -130,7 +145,31 @@ class TagIterator:
130
145
  self.pos -= amount
131
146
 
132
147
  def _search(self, pattern: re.Pattern) -> Optional[re.Match]:
133
- return pattern.search(self.text, self.pos)
148
+ # Check to see if we have cached a search for this pattern already.
149
+ positioned_match = self._past_matches.get(pattern)
150
+
151
+ if positioned_match is None or positioned_match.start_pos > self.pos:
152
+ # We did not have a cached search, or we did, but it was done at a location
153
+ # further along in the string and can't be used. Do a search and cache it.
154
+ match = pattern.search(self.text, self.pos)
155
+ self._past_matches[pattern] = PositionedMatch(self.pos, match)
156
+ else:
157
+ # We have a cached search and its start position falls before (or at) the
158
+ # current search position...
159
+ if positioned_match.match is None:
160
+ # ...but there is no match in the rest of the text.
161
+ match = None
162
+ elif positioned_match.match.start() >= self.pos:
163
+ # ...and there is a match we can reuse, because we have not yet passed
164
+ # the start position of the match. It's still the next match.
165
+ match = positioned_match.match
166
+ else:
167
+ # ...but we have passed the start of the cached match, and need to do a
168
+ # new search from our current position and cache it.
169
+ match = pattern.search(self.text, self.pos)
170
+ self._past_matches[pattern] = PositionedMatch(self.pos, match)
171
+
172
+ return match
134
173
 
135
174
  def _match(self, pattern: re.Pattern) -> Optional[re.Match]:
136
175
  return pattern.match(self.text, self.pos)
@@ -91,15 +91,18 @@ class BaseEvent:
91
91
 
92
92
  def to_dict(self):
93
93
  return MessageToDict(
94
- self.pb_msg, preserving_proto_field_name=True, including_default_value_fields=True
94
+ self.pb_msg,
95
+ preserving_proto_field_name=True,
96
+ always_print_fields_with_no_presence=True,
95
97
  )
96
98
 
97
99
  def to_json(self) -> str:
98
100
  return MessageToJson(
99
101
  self.pb_msg,
100
102
  preserving_proto_field_name=True,
101
- including_default_value_fields=True,
103
+ always_print_fields_with_no_presence=True,
102
104
  indent=None,
105
+ sort_keys=True,
103
106
  )
104
107
 
105
108
  def level_tag(self) -> EventLevel:
@@ -97,7 +97,7 @@ def msg_to_dict(msg: EventMsg) -> dict:
97
97
  msg_dict = MessageToDict(
98
98
  msg,
99
99
  preserving_proto_field_name=True,
100
- including_default_value_fields=True, # type: ignore
100
+ always_print_fields_with_no_presence=True,
101
101
  )
102
102
  except Exception as exc:
103
103
  event_type = type(msg).__name__
@@ -13,11 +13,11 @@ from dbt_common.events.base_types import EventLevel, EventMsg
13
13
  from dbt_common.events.format import timestamp_to_datetime_string
14
14
  from dbt_common.utils.encoding import ForgivingJSONEncoder
15
15
 
16
- PRINT_EVENT_NAME = "PrintEvent"
16
+ PRINT_EVENT_NAMES = ("PrintEvent", "ShowNode", "CompiledNode")
17
17
 
18
18
 
19
19
  def _is_print_event(msg: EventMsg) -> bool:
20
- return msg.info.name == PRINT_EVENT_NAME
20
+ return msg.info.name in PRINT_EVENT_NAMES
21
21
 
22
22
 
23
23
  # A Filter is a function which takes a BaseEvent and returns True if the event
@@ -1,12 +1,22 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # NO CHECKED-IN PROTOBUF GENCODE
3
4
  # source: types.proto
4
- # Protobuf Python Version: 4.25.2
5
+ # Protobuf Python Version: 5.28.3
5
6
  """Generated protocol buffer code."""
6
7
  from google.protobuf import descriptor as _descriptor
7
8
  from google.protobuf import descriptor_pool as _descriptor_pool
9
+ from google.protobuf import runtime_version as _runtime_version
8
10
  from google.protobuf import symbol_database as _symbol_database
9
11
  from google.protobuf.internal import builder as _builder
12
+ _runtime_version.ValidateProtobufRuntimeVersion(
13
+ _runtime_version.Domain.PUBLIC,
14
+ 5,
15
+ 28,
16
+ 3,
17
+ '',
18
+ 'types.proto'
19
+ )
10
20
  # @@protoc_insertion_point(imports)
11
21
 
12
22
  _sym_db = _symbol_database.Default()
@@ -20,9 +30,9 @@ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0btypes.proto\x1
20
30
  _globals = globals()
21
31
  _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
22
32
  _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'types_pb2', _globals)
23
- if _descriptor._USE_C_DESCRIPTORS == False:
24
- DESCRIPTOR._options = None
25
- _globals['_EVENTINFO_EXTRAENTRY']._options = None
33
+ if not _descriptor._USE_C_DESCRIPTORS:
34
+ DESCRIPTOR._loaded_options = None
35
+ _globals['_EVENTINFO_EXTRAENTRY']._loaded_options = None
26
36
  _globals['_EVENTINFO_EXTRAENTRY']._serialized_options = b'8\001'
27
37
  _globals['_EVENTINFO']._serialized_start=62
28
38
  _globals['_EVENTINFO']._serialized_end=335
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: dbt-common
3
- Version: 1.11.0
3
+ Version: 1.13.0
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
@@ -8,22 +8,20 @@ Project-URL: Issues, https://github.com/dbt-labs/dbt-common/issues
8
8
  Project-URL: Changelog, https://github.com/dbt-labs/dbt-common/blob/main/CHANGELOG.md
9
9
  Author-email: dbt Labs <info@dbtlabs.com>
10
10
  Maintainer-email: dbt Labs <info@dbtlabs.com>
11
- License-Expression: Apache-2.0
12
- License-File: LICENSE
11
+ License: Apache-2.0
13
12
  Classifier: Development Status :: 2 - Pre-Alpha
14
13
  Classifier: License :: OSI Approved :: Apache Software License
15
14
  Classifier: Operating System :: MacOS :: MacOS X
16
15
  Classifier: Operating System :: Microsoft :: Windows
17
16
  Classifier: Operating System :: POSIX :: Linux
18
17
  Classifier: Programming Language :: Python
19
- Classifier: Programming Language :: Python :: 3.8
20
18
  Classifier: Programming Language :: Python :: 3.9
21
19
  Classifier: Programming Language :: Python :: 3.10
22
20
  Classifier: Programming Language :: Python :: 3.11
23
21
  Classifier: Programming Language :: Python :: 3.12
24
22
  Classifier: Programming Language :: Python :: Implementation :: CPython
25
23
  Classifier: Programming Language :: Python :: Implementation :: PyPy
26
- Requires-Python: >=3.8
24
+ Requires-Python: >=3.9
27
25
  Requires-Dist: agate<1.10,>=1.7.0
28
26
  Requires-Dist: colorama<0.5,>=0.3.9
29
27
  Requires-Dist: deepdiff<8.0,>=7.0
@@ -32,7 +30,7 @@ Requires-Dist: jinja2<4,>=3.1.3
32
30
  Requires-Dist: jsonschema<5.0,>=4.0
33
31
  Requires-Dist: mashumaro[msgpack]<4.0,>=3.9
34
32
  Requires-Dist: pathspec<0.13,>=0.9
35
- Requires-Dist: protobuf<5.0.0,>=4.0.0
33
+ Requires-Dist: protobuf<6.0,>=5.0
36
34
  Requires-Dist: python-dateutil<3.0,>=2.0
37
35
  Requires-Dist: requests<3.0.0
38
36
  Requires-Dist: typing-extensions<5.0,>=4.4
@@ -49,7 +47,7 @@ Requires-Dist: mypy<2.0,>=1.3; extra == 'lint'
49
47
  Requires-Dist: pytest<8.0,>=7.3; extra == 'lint'
50
48
  Requires-Dist: types-jinja2<3.0,>=2.11; extra == 'lint'
51
49
  Requires-Dist: types-jsonschema<5.0,>=4.17; extra == 'lint'
52
- Requires-Dist: types-protobuf<5.0,>=4.24; extra == 'lint'
50
+ Requires-Dist: types-protobuf<6.0,>=5.0; extra == 'lint'
53
51
  Requires-Dist: types-python-dateutil<3.0,>=2.8; extra == 'lint'
54
52
  Requires-Dist: types-pyyaml<7.0,>=6.0; extra == 'lint'
55
53
  Requires-Dist: types-requests; extra == 'lint'
@@ -1,6 +1,6 @@
1
- dbt_common/__about__.py,sha256=mD8RxZIPreXVMDcN4OLaJBmakjmOUITJu4JM34eJwD8,19
1
+ dbt_common/__about__.py,sha256=M85oP8JJdZ4yZHcp9qfGYLKUYvnN3kTyQosVcYPCPow,19
2
2
  dbt_common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- dbt_common/behavior_flags.py,sha256=tflh5PubIgEuogslprvnOEA2tM7e7opK6i8GOTnwrgw,4883
3
+ dbt_common/behavior_flags.py,sha256=hQzxCqQSweJbRp_xoQqNnlUF77PBuOdCdLOSdcBlkxk,4885
4
4
  dbt_common/constants.py,sha256=-Y5DIL1SDPQWtlCNizXRYxFgbx1D7LaLs1ysamvGMRk,278
5
5
  dbt_common/context.py,sha256=rk4EYBU4SpDXRhqbSvDTJwojilxPSoaiEdOxkXow_BU,2549
6
6
  dbt_common/dataclass_schema.py,sha256=u2S0dxwxIghv8RMqC91HlWZJVxmsC_844yZQaGyOwdY,5563
@@ -12,7 +12,7 @@ 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=xoJK9Y0F93U2PKfT_3SJbBopCGYCtl7LiwKuylXnrEE,12947
15
+ dbt_common/clients/_jinja_blocks.py,sha256=5I_VEWkkW_54uK09ErP_8ey7wj-OOXvt1OHqr73HLOk,14879
16
16
  dbt_common/clients/agate_helper.py,sha256=anKKgKV5PSnFRuFeBwRMdHK3JCaQoUqB2ZXHD0su0Wo,9123
17
17
  dbt_common/clients/jinja.py,sha256=GzpW1BN3W-__YFQ2amyx85Z_qwOOZXEwjmoTIr70HlA,19787
18
18
  dbt_common/clients/system.py,sha256=aoUBtOuXVmkOyj6IhhJ3Y4a7JFzPO2F_zKyOtz3xy44,23932
@@ -27,19 +27,19 @@ dbt_common/contracts/config/metadata.py,sha256=X47-tEA8q2ZfSMcYv0godUwTSVjt8NI77
27
27
  dbt_common/contracts/config/properties.py,sha256=gWt6xsP4rVOqRKhmagiUhWnDynzD9mykfMYMTviwpEU,2281
28
28
  dbt_common/events/README.md,sha256=CSwVajoxCAqOug2UCnXldH1EUK7Kjf3rcq7z9ACjrss,3023
29
29
  dbt_common/events/__init__.py,sha256=av08vfpxo0ek7PqZNtMxY8FODJ3xwph4ehRxgInx4LA,383
30
- dbt_common/events/base_types.py,sha256=MHlj-DzOmhG9Ds2kNqXtSWxmy_RlwAOFVKu6-WVs3Ik,5460
30
+ dbt_common/events/base_types.py,sha256=bdDMbawAV0FkxmvuxgsTev82vxTuyu6rJiSkvEQPsO8,5525
31
31
  dbt_common/events/contextvars.py,sha256=EIs1P6NrJzx_IAV17x5cVqOAS4Lqbu6oc0etHtWCJOo,3097
32
32
  dbt_common/events/event_handler.py,sha256=jfi0PyqIOGnXCG9HEa0VIVULqNvXs1RYmAg0b50ChQs,1385
33
33
  dbt_common/events/event_manager.py,sha256=IIUwSyt_RcBbUI_iE5mnpmZt2uW7lG49RXOWz2VlUv0,2300
34
34
  dbt_common/events/event_manager_client.py,sha256=VKlIYJPcexmDKnidkyrs8BIuNZ1_CwDFGz-gBM2SAvo,1193
35
35
  dbt_common/events/format.py,sha256=x1RWDZ8G7ZMHmxdld6Q4VXca4kvnhiQOIaQXkC6Uo0Q,1609
36
- dbt_common/events/functions.py,sha256=K-R-FBTeO03U51gtMBu1EUcNsIAsgw_e5spWxLJ44VE,4762
36
+ dbt_common/events/functions.py,sha256=_7CLApCKb9KhurOgfVRpW-yGKGE_yjYUguiAaLxVwnw,4752
37
37
  dbt_common/events/helpers.py,sha256=CfsWwNDjsLJkPIgOtAfuLEnZ3rGUKeYsH8aDtCW12OA,410
38
38
  dbt_common/events/interfaces.py,sha256=hEDeDoB0FW2RYHVZBG7gebEt_mUVBzkn1yPubpaxs-s,147
39
- dbt_common/events/logger.py,sha256=mAUNLZlIIOl3T2u7KOe8FF_deTNNe1CRJqmkPw4YH1U,6728
39
+ dbt_common/events/logger.py,sha256=iBxMhFhAo8wL4NA4Z31pf644I0tsCOWIrt-k4d7EzaY,6760
40
40
  dbt_common/events/types.proto,sha256=Ujl0O-X-pat8vlo2C0TMH1LZqa8EP_9f8k2TjbFuCV8,2276
41
41
  dbt_common/events/types.py,sha256=MXCmG7qaj7hLbDZjjazjWftPTfoLjhNPATPMirO0DvU,4475
42
- dbt_common/events/types_pb2.py,sha256=oFjR6pFqz3_Nk8wWIrVB9y6inNTxnj-CSGr2g8dnFz4,7167
42
+ dbt_common/events/types_pb2.py,sha256=oQauUKUU_cBz3SskNvAYeWcp_OcA8dZPOgEYNeifThQ,7408
43
43
  dbt_common/exceptions/__init__.py,sha256=X_Uw7BxOzXev_9JMYfs5Cm-_i_Qf2PJim8_-dDJI7Y8,361
44
44
  dbt_common/exceptions/base.py,sha256=23ijq-AtQgUSvZ9JbrCIZ87Pbyn8iEYezX95IXAZ4FY,7783
45
45
  dbt_common/exceptions/cache.py,sha256=0z4fBcdNZMAR41YbPRo2GN0__xAMaYs8Uc-t3hjmVio,2532
@@ -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.11.0.dist-info/METADATA,sha256=MQj_0ruvmXW57fvRN94WNtYjX71MDdxcaYic-a9QrOg,5299
61
- dbt_common-1.11.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
62
- dbt_common-1.11.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
63
- dbt_common-1.11.0.dist-info/RECORD,,
60
+ dbt_common-1.13.0.dist-info/METADATA,sha256=LMXT2OegSelr0vg0b1mMBO79jYzoAb5DpWx7DI16xfg,5211
61
+ dbt_common-1.13.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
62
+ dbt_common-1.13.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
63
+ dbt_common-1.13.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.25.0
2
+ Generator: hatchling 1.26.3
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any