dbt-common 1.6.0__py3-none-any.whl → 1.8.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 +1 -1
- dbt_common/behavior_flags.py +125 -0
- dbt_common/clients/agate_helper.py +2 -2
- dbt_common/clients/jinja.py +8 -6
- dbt_common/clients/system.py +27 -1
- dbt_common/context.py +2 -2
- dbt_common/contracts/config/base.py +12 -12
- dbt_common/contracts/util.py +10 -4
- dbt_common/dataclass_schema.py +4 -5
- dbt_common/events/contextvars.py +1 -1
- dbt_common/events/types.proto +16 -0
- dbt_common/events/types.py +39 -0
- dbt_common/events/types_pb2.py +49 -45
- dbt_common/exceptions/base.py +13 -13
- dbt_common/exceptions/system.py +2 -2
- dbt_common/invocation.py +1 -1
- dbt_common/semver.py +14 -14
- dbt_common/utils/casting.py +3 -2
- dbt_common/utils/connection.py +2 -1
- dbt_common/utils/jinja.py +7 -5
- {dbt_common-1.6.0.dist-info → dbt_common-1.8.0.dist-info}/METADATA +1 -1
- {dbt_common-1.6.0.dist-info → dbt_common-1.8.0.dist-info}/RECORD +24 -23
- {dbt_common-1.6.0.dist-info → dbt_common-1.8.0.dist-info}/WHEEL +0 -0
- {dbt_common-1.6.0.dist-info → dbt_common-1.8.0.dist-info}/licenses/LICENSE +0 -0
dbt_common/__about__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
version = "1.
|
1
|
+
version = "1.8.0"
|
@@ -0,0 +1,125 @@
|
|
1
|
+
import inspect
|
2
|
+
from typing import Any, Dict, List, TypedDict
|
3
|
+
|
4
|
+
try:
|
5
|
+
from typing import NotRequired
|
6
|
+
except ImportError:
|
7
|
+
# NotRequired was introduced in Python 3.11
|
8
|
+
# This is the suggested way to implement a TypedDict with optional arguments
|
9
|
+
from typing import Optional as NotRequired
|
10
|
+
|
11
|
+
from dbt_common.events.functions import fire_event
|
12
|
+
from dbt_common.events.types import BehaviorDeprecationEvent
|
13
|
+
from dbt_common.exceptions import CompilationError
|
14
|
+
|
15
|
+
|
16
|
+
class BehaviorFlag(TypedDict):
|
17
|
+
"""
|
18
|
+
Configuration used to create a BehaviorFlagRendered instance
|
19
|
+
|
20
|
+
Args:
|
21
|
+
name: the name of the behavior flag
|
22
|
+
default: default setting, starts as False, becomes True after a bake-in period
|
23
|
+
deprecation_version: the version when the default will change to True
|
24
|
+
deprecation_message: an additional message to send when the flag evaluates to False
|
25
|
+
docs_url: the url to the relevant docs on docs.getdbt.com
|
26
|
+
"""
|
27
|
+
|
28
|
+
name: str
|
29
|
+
default: bool
|
30
|
+
source: NotRequired[str]
|
31
|
+
deprecation_version: NotRequired[str]
|
32
|
+
deprecation_message: NotRequired[str]
|
33
|
+
docs_url: NotRequired[str]
|
34
|
+
|
35
|
+
|
36
|
+
class BehaviorFlagRendered:
|
37
|
+
"""
|
38
|
+
A rendered behavior flag that gets used throughout dbt packages
|
39
|
+
|
40
|
+
Args:
|
41
|
+
flag: the configuration for the behavior flag
|
42
|
+
user_overrides: a set of user settings, one of which may be an override on this behavior flag
|
43
|
+
"""
|
44
|
+
|
45
|
+
def __init__(self, flag: BehaviorFlag, user_overrides: Dict[str, Any]) -> None:
|
46
|
+
self.name = flag["name"]
|
47
|
+
self.setting = user_overrides.get(flag["name"], flag["default"])
|
48
|
+
self.deprecation_event = self._deprecation_event(flag)
|
49
|
+
|
50
|
+
@property
|
51
|
+
def setting(self) -> bool:
|
52
|
+
if self._setting is False:
|
53
|
+
fire_event(self.deprecation_event)
|
54
|
+
return self._setting
|
55
|
+
|
56
|
+
@setting.setter
|
57
|
+
def setting(self, value: bool) -> None:
|
58
|
+
self._setting = value
|
59
|
+
|
60
|
+
@property
|
61
|
+
def no_warn(self) -> bool:
|
62
|
+
return self._setting
|
63
|
+
|
64
|
+
def _deprecation_event(self, flag: BehaviorFlag) -> BehaviorDeprecationEvent:
|
65
|
+
return BehaviorDeprecationEvent(
|
66
|
+
flag_name=flag["name"],
|
67
|
+
flag_source=flag.get("source", self._default_source()),
|
68
|
+
deprecation_version=flag.get("deprecation_version"),
|
69
|
+
deprecation_message=flag.get("deprecation_message"),
|
70
|
+
docs_url=flag.get("docs_url"),
|
71
|
+
)
|
72
|
+
|
73
|
+
@staticmethod
|
74
|
+
def _default_source() -> str:
|
75
|
+
"""
|
76
|
+
If the maintainer did not provide a source, default to the module that called this class.
|
77
|
+
For adapters, this will likely be `dbt.adapters.<foo>.impl` for `dbt-foo`.
|
78
|
+
"""
|
79
|
+
for frame in inspect.stack():
|
80
|
+
if module := inspect.getmodule(frame[0]):
|
81
|
+
if module.__name__ != __name__:
|
82
|
+
return module.__name__
|
83
|
+
return "Unknown"
|
84
|
+
|
85
|
+
def __bool__(self) -> bool:
|
86
|
+
return self.setting
|
87
|
+
|
88
|
+
|
89
|
+
class Behavior:
|
90
|
+
"""
|
91
|
+
A collection of behavior flags
|
92
|
+
|
93
|
+
This is effectively a dictionary that supports dot notation for easy reference, e.g.:
|
94
|
+
```python
|
95
|
+
if adapter.behavior.my_flag:
|
96
|
+
...
|
97
|
+
|
98
|
+
if adapter.behavior.my_flag.no_warn: # this will not fire the deprecation event
|
99
|
+
...
|
100
|
+
```
|
101
|
+
```jinja
|
102
|
+
{% if adapter.behavior.my_flag %}
|
103
|
+
...
|
104
|
+
{% endif %}
|
105
|
+
|
106
|
+
{% if adapter.behavior.my_flag.no_warn %} {# this will not fire the deprecation event #}
|
107
|
+
...
|
108
|
+
{% endif %}
|
109
|
+
```
|
110
|
+
|
111
|
+
Args:
|
112
|
+
flags: a list of configurations, one for each behavior flag
|
113
|
+
user_overrides: a set of user settings, which may include overrides on one or more of the behavior flags
|
114
|
+
"""
|
115
|
+
|
116
|
+
_flags: List[BehaviorFlagRendered]
|
117
|
+
|
118
|
+
def __init__(self, flags: List[BehaviorFlag], user_overrides: Dict[str, Any]) -> None:
|
119
|
+
self._flags = [BehaviorFlagRendered(flag, user_overrides) for flag in flags]
|
120
|
+
|
121
|
+
def __getattr__(self, name: str) -> BehaviorFlagRendered:
|
122
|
+
for flag in self._flags:
|
123
|
+
if flag.name == name:
|
124
|
+
return flag
|
125
|
+
raise CompilationError(f"The flag {name} has not be registered.")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from codecs import BOM_UTF8
|
2
2
|
|
3
|
-
import agate
|
3
|
+
import agate
|
4
4
|
import datetime
|
5
5
|
import isodate
|
6
6
|
import json
|
@@ -149,7 +149,7 @@ def as_matrix(table):
|
|
149
149
|
return [r.values() for r in table.rows.values()]
|
150
150
|
|
151
151
|
|
152
|
-
def from_csv(abspath, text_columns, delimiter=","):
|
152
|
+
def from_csv(abspath, text_columns, delimiter=",") -> agate.Table:
|
153
153
|
type_tester = build_type_tester(text_columns=text_columns)
|
154
154
|
with open(abspath, encoding="utf-8") as fp:
|
155
155
|
if fp.read(1) != BOM:
|
dbt_common/clients/jinja.py
CHANGED
@@ -9,12 +9,12 @@ from itertools import chain, islice
|
|
9
9
|
from typing import Any, Callable, Dict, Iterator, List, Mapping, Optional, Union, Set, Type
|
10
10
|
from typing_extensions import Protocol
|
11
11
|
|
12
|
-
import jinja2
|
13
|
-
import jinja2.ext
|
14
|
-
import jinja2.nativetypes
|
15
|
-
import jinja2.nodes
|
16
|
-
import jinja2.parser
|
17
|
-
import jinja2.sandbox
|
12
|
+
import jinja2
|
13
|
+
import jinja2.ext
|
14
|
+
import jinja2.nativetypes
|
15
|
+
import jinja2.nodes
|
16
|
+
import jinja2.parser
|
17
|
+
import jinja2.sandbox
|
18
18
|
|
19
19
|
from dbt_common.tests import test_caching_enabled
|
20
20
|
from dbt_common.utils.jinja import (
|
@@ -124,6 +124,7 @@ class MacroFuzzTemplate(jinja2.nativetypes.NativeTemplate):
|
|
124
124
|
"shared or locals parameters."
|
125
125
|
)
|
126
126
|
|
127
|
+
vars = {} if vars is None else vars
|
127
128
|
parent = ChainMap(vars, self.globals) if self.globals else vars
|
128
129
|
|
129
130
|
return self.environment.context_class(self.environment, parent, self.name, self.blocks)
|
@@ -544,6 +545,7 @@ _TESTING_BLOCKS_CACHE: Dict[int, List[Union[BlockData, BlockTag]]] = {}
|
|
544
545
|
|
545
546
|
def _get_blocks_hash(text: str, allowed_blocks: Optional[Set[str]], collect_raw_data: bool) -> int:
|
546
547
|
"""Provides a hash function over the arguments to extract_toplevel_blocks, in order to support caching."""
|
548
|
+
allowed_blocks = allowed_blocks or set()
|
547
549
|
allowed_tuple = tuple(sorted(allowed_blocks) or [])
|
548
550
|
return text.__hash__() + allowed_tuple.__hash__() + collect_raw_data.__hash__()
|
549
551
|
|
dbt_common/clients/system.py
CHANGED
@@ -52,6 +52,7 @@ class FindMatchingParams:
|
|
52
52
|
root_path: str
|
53
53
|
relative_paths_to_search: List[str]
|
54
54
|
file_pattern: str
|
55
|
+
|
55
56
|
# ignore_spec: Optional[PathSpec] = None
|
56
57
|
|
57
58
|
def __init__(
|
@@ -608,11 +609,36 @@ def rename(from_path: str, to_path: str, force: bool = False) -> None:
|
|
608
609
|
shutil.move(from_path, to_path)
|
609
610
|
|
610
611
|
|
612
|
+
def safe_extract(tarball: tarfile.TarFile, path: str = ".") -> None:
|
613
|
+
"""
|
614
|
+
Fix for CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
|
615
|
+
Solution copied from https://github.com/mindsdb/mindsdb/blob/main/mindsdb/utilities/fs.py
|
616
|
+
"""
|
617
|
+
|
618
|
+
def _is_within_directory(directory, target):
|
619
|
+
abs_directory = os.path.abspath(directory)
|
620
|
+
abs_target = os.path.abspath(target)
|
621
|
+
prefix = os.path.commonprefix([abs_directory, abs_target])
|
622
|
+
return prefix == abs_directory
|
623
|
+
|
624
|
+
# for py >= 3.12
|
625
|
+
if hasattr(tarball, "data_filter"):
|
626
|
+
tarball.extractall(path, filter="data")
|
627
|
+
else:
|
628
|
+
members = tarball.getmembers()
|
629
|
+
for member in members:
|
630
|
+
member_path = os.path.join(path, member.name)
|
631
|
+
if not _is_within_directory(path, member_path):
|
632
|
+
raise tarfile.OutsideDestinationError(member, path)
|
633
|
+
|
634
|
+
tarball.extractall(path, members=members)
|
635
|
+
|
636
|
+
|
611
637
|
def untar_package(tar_path: str, dest_dir: str, rename_to: Optional[str] = None) -> None:
|
612
638
|
tar_path = convert_path(tar_path)
|
613
639
|
tar_dir_name = None
|
614
640
|
with tarfile.open(tar_path, "r:gz") as tarball:
|
615
|
-
tarball
|
641
|
+
safe_extract(tarball, dest_dir)
|
616
642
|
tar_dir_name = os.path.commonprefix(tarball.getnames())
|
617
643
|
if rename_to:
|
618
644
|
downloaded_path = os.path.join(dest_dir, tar_dir_name)
|
dbt_common/context.py
CHANGED
@@ -6,7 +6,7 @@ from dbt_common.constants import PRIVATE_ENV_PREFIX, SECRET_ENV_PREFIX
|
|
6
6
|
from dbt_common.record import Recorder
|
7
7
|
|
8
8
|
|
9
|
-
class CaseInsensitiveMapping(Mapping):
|
9
|
+
class CaseInsensitiveMapping(Mapping[str, str]):
|
10
10
|
def __init__(self, env: Mapping[str, str]):
|
11
11
|
self._env = {k.casefold(): (k, v) for k, v in env.items()}
|
12
12
|
|
@@ -65,7 +65,7 @@ _INVOCATION_CONTEXT_VAR: ContextVar[InvocationContext] = ContextVar("DBT_INVOCAT
|
|
65
65
|
|
66
66
|
|
67
67
|
def reliably_get_invocation_var() -> ContextVar[InvocationContext]:
|
68
|
-
invocation_var: Optional[ContextVar] = next(
|
68
|
+
invocation_var: Optional[ContextVar[InvocationContext]] = next(
|
69
69
|
(cv for cv in copy_context() if cv.name == _INVOCATION_CONTEXT_VAR.name), None
|
70
70
|
)
|
71
71
|
|
@@ -4,7 +4,7 @@ from __future__ import annotations
|
|
4
4
|
from dataclasses import dataclass, Field
|
5
5
|
|
6
6
|
from itertools import chain
|
7
|
-
from typing import Callable, Dict,
|
7
|
+
from typing import Any, Callable, Dict, Iterator, List, Type, TypeVar
|
8
8
|
|
9
9
|
from dbt_common.contracts.config.metadata import Metadata
|
10
10
|
from dbt_common.exceptions import CompilationError, DbtInternalError
|
@@ -17,11 +17,11 @@ T = TypeVar("T", bound="BaseConfig")
|
|
17
17
|
@dataclass
|
18
18
|
class BaseConfig(AdditionalPropertiesAllowed, Replaceable):
|
19
19
|
# enable syntax like: config['key']
|
20
|
-
def __getitem__(self, key):
|
20
|
+
def __getitem__(self, key: str) -> Any:
|
21
21
|
return self.get(key)
|
22
22
|
|
23
23
|
# like doing 'get' on a dictionary
|
24
|
-
def get(self, key, default=None):
|
24
|
+
def get(self, key: str, default: Any = None) -> Any:
|
25
25
|
if hasattr(self, key):
|
26
26
|
return getattr(self, key)
|
27
27
|
elif key in self._extra:
|
@@ -30,13 +30,13 @@ class BaseConfig(AdditionalPropertiesAllowed, Replaceable):
|
|
30
30
|
return default
|
31
31
|
|
32
32
|
# enable syntax like: config['key'] = value
|
33
|
-
def __setitem__(self, key, value):
|
33
|
+
def __setitem__(self, key: str, value) -> None:
|
34
34
|
if hasattr(self, key):
|
35
35
|
setattr(self, key, value)
|
36
36
|
else:
|
37
37
|
self._extra[key] = value
|
38
38
|
|
39
|
-
def __delitem__(self, key):
|
39
|
+
def __delitem__(self, key: str) -> None:
|
40
40
|
if hasattr(self, key):
|
41
41
|
msg = (
|
42
42
|
'Error, tried to delete config key "{}": Cannot delete ' "built-in keys"
|
@@ -45,7 +45,7 @@ class BaseConfig(AdditionalPropertiesAllowed, Replaceable):
|
|
45
45
|
else:
|
46
46
|
del self._extra[key]
|
47
47
|
|
48
|
-
def _content_iterator(self, include_condition: Callable[[Field], bool]):
|
48
|
+
def _content_iterator(self, include_condition: Callable[[Field[Any]], bool]) -> Iterator[str]:
|
49
49
|
seen = set()
|
50
50
|
for fld, _ in self._get_fields():
|
51
51
|
seen.add(fld.name)
|
@@ -57,10 +57,10 @@ class BaseConfig(AdditionalPropertiesAllowed, Replaceable):
|
|
57
57
|
seen.add(key)
|
58
58
|
yield key
|
59
59
|
|
60
|
-
def __iter__(self):
|
60
|
+
def __iter__(self) -> Iterator[str]:
|
61
61
|
yield from self._content_iterator(include_condition=lambda f: True)
|
62
62
|
|
63
|
-
def __len__(self):
|
63
|
+
def __len__(self) -> int:
|
64
64
|
return len(self._get_fields()) + len(self._extra)
|
65
65
|
|
66
66
|
@staticmethod
|
@@ -76,7 +76,7 @@ class BaseConfig(AdditionalPropertiesAllowed, Replaceable):
|
|
76
76
|
elif key in unrendered and key not in other:
|
77
77
|
return False
|
78
78
|
else:
|
79
|
-
return unrendered[key] == other[key]
|
79
|
+
return bool(unrendered[key] == other[key])
|
80
80
|
|
81
81
|
@classmethod
|
82
82
|
def same_contents(cls, unrendered: Dict[str, Any], other: Dict[str, Any]) -> bool:
|
@@ -203,11 +203,11 @@ class CompareBehavior(Metadata):
|
|
203
203
|
return "compare"
|
204
204
|
|
205
205
|
@classmethod
|
206
|
-
def should_include(cls, fld: Field) -> bool:
|
206
|
+
def should_include(cls, fld: Field[Any]) -> bool:
|
207
207
|
return cls.from_field(fld) == cls.Include
|
208
208
|
|
209
209
|
|
210
|
-
def _listify(value: Any) -> List:
|
210
|
+
def _listify(value: Any) -> List[Any]:
|
211
211
|
if isinstance(value, list):
|
212
212
|
return value[:]
|
213
213
|
else:
|
@@ -221,7 +221,7 @@ def _merge_field_value(
|
|
221
221
|
merge_behavior: MergeBehavior,
|
222
222
|
self_value: Any,
|
223
223
|
other_value: Any,
|
224
|
-
):
|
224
|
+
) -> Any:
|
225
225
|
if merge_behavior == MergeBehavior.Clobber:
|
226
226
|
return other_value
|
227
227
|
elif merge_behavior == MergeBehavior.Append:
|
dbt_common/contracts/util.py
CHANGED
@@ -1,21 +1,27 @@
|
|
1
1
|
import dataclasses
|
2
|
+
from typing import Any, TypeVar
|
3
|
+
|
4
|
+
_R = TypeVar("_R", bound="Replaceable")
|
2
5
|
|
3
6
|
|
4
7
|
# TODO: remove from dbt_common.contracts.util:: Replaceable + references
|
5
8
|
class Replaceable:
|
6
|
-
def replace(self, **kwargs):
|
7
|
-
return dataclasses.replace(self, **kwargs)
|
9
|
+
def replace(self: _R, **kwargs: Any) -> _R:
|
10
|
+
return dataclasses.replace(self, **kwargs) # type: ignore
|
11
|
+
|
12
|
+
|
13
|
+
_M = TypeVar("_M", bound="Mergeable")
|
8
14
|
|
9
15
|
|
10
16
|
class Mergeable(Replaceable):
|
11
|
-
def merged(self, *args):
|
17
|
+
def merged(self: _M, *args: Any) -> _M:
|
12
18
|
"""Perform a shallow merge, where the last non-None write wins. This is
|
13
19
|
intended to merge dataclasses that are a collection of optional values.
|
14
20
|
"""
|
15
21
|
replacements = {}
|
16
22
|
cls = type(self)
|
17
23
|
for arg in args:
|
18
|
-
for field in dataclasses.fields(cls):
|
24
|
+
for field in dataclasses.fields(cls): # type: ignore
|
19
25
|
value = getattr(arg, field.name)
|
20
26
|
if value is not None:
|
21
27
|
replacements[field.name] = value
|
dbt_common/dataclass_schema.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import Any,
|
1
|
+
from typing import Any, ClassVar, Dict, get_type_hints, List, Optional, Tuple, Union
|
2
2
|
import re
|
3
3
|
import jsonschema
|
4
4
|
from dataclasses import fields, Field
|
@@ -6,7 +6,6 @@ from enum import Enum
|
|
6
6
|
from datetime import datetime
|
7
7
|
from dateutil.parser import parse
|
8
8
|
|
9
|
-
# type: ignore
|
10
9
|
from mashumaro.config import (
|
11
10
|
TO_DICT_ADD_OMIT_NONE_FLAG,
|
12
11
|
ADD_SERIALIZATION_CONTEXT,
|
@@ -33,8 +32,8 @@ class DateTimeSerialization(SerializationStrategy):
|
|
33
32
|
out += "Z"
|
34
33
|
return out
|
35
34
|
|
36
|
-
def deserialize(self, value) -> datetime:
|
37
|
-
return value if isinstance(value, datetime) else parse(
|
35
|
+
def deserialize(self, value: Union[datetime, str]) -> datetime:
|
36
|
+
return value if isinstance(value, datetime) else parse(value)
|
38
37
|
|
39
38
|
|
40
39
|
class dbtMashConfig(MashBaseConfig):
|
@@ -92,7 +91,7 @@ class dbtClassMixin(DataClassMessagePackMixin):
|
|
92
91
|
return json_schema
|
93
92
|
|
94
93
|
@classmethod
|
95
|
-
def validate(cls, data):
|
94
|
+
def validate(cls, data: Any) -> None:
|
96
95
|
json_schema = cls.json_schema()
|
97
96
|
validator = jsonschema.Draft7Validator(json_schema)
|
98
97
|
error = next(iter(validator.iter_errors(data)), None)
|
dbt_common/events/contextvars.py
CHANGED
dbt_common/events/types.proto
CHANGED
@@ -23,6 +23,22 @@ message GenericMessage {
|
|
23
23
|
EventInfo info = 1;
|
24
24
|
}
|
25
25
|
|
26
|
+
// D - Deprecations
|
27
|
+
|
28
|
+
// D018
|
29
|
+
message BehaviorDeprecationEvent {
|
30
|
+
string flag_name = 1;
|
31
|
+
string flag_source = 2;
|
32
|
+
string deprecation_version = 3;
|
33
|
+
string deprecation_message = 4;
|
34
|
+
string docs_url = 5;
|
35
|
+
}
|
36
|
+
|
37
|
+
message BehaviorDeprecationEventMsg {
|
38
|
+
EventInfo info = 1;
|
39
|
+
BehaviorDeprecationEvent data = 2;
|
40
|
+
}
|
41
|
+
|
26
42
|
// M - Deps generation
|
27
43
|
|
28
44
|
// M020
|
dbt_common/events/types.py
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
+
from typing import Optional
|
2
|
+
|
1
3
|
from dbt_common.events.base_types import (
|
2
4
|
DebugLevel,
|
3
5
|
InfoLevel,
|
6
|
+
WarnLevel,
|
4
7
|
)
|
8
|
+
from dbt_common.ui import warning_tag
|
5
9
|
|
6
10
|
|
7
11
|
# The classes in this file represent the data necessary to describe a
|
@@ -28,6 +32,41 @@ from dbt_common.events.base_types import (
|
|
28
32
|
#
|
29
33
|
# The basic idea is that event codes roughly translate to the natural order of running a dbt task
|
30
34
|
|
35
|
+
|
36
|
+
# =======================================================
|
37
|
+
# D - Deprecations
|
38
|
+
# =======================================================
|
39
|
+
|
40
|
+
|
41
|
+
class BehaviorDeprecationEvent(WarnLevel):
|
42
|
+
flag_name: str
|
43
|
+
flag_source: str
|
44
|
+
deprecation_version: Optional[str]
|
45
|
+
deprecation_message: Optional[str]
|
46
|
+
docs_url: Optional[str]
|
47
|
+
|
48
|
+
def code(self) -> str:
|
49
|
+
return "D018"
|
50
|
+
|
51
|
+
def message(self) -> str:
|
52
|
+
msg = f"The legacy behavior controlled by `{self.flag_name}` is deprecated.\n"
|
53
|
+
|
54
|
+
if self.deprecation_version:
|
55
|
+
msg = (
|
56
|
+
f"The legacy behavior is expected to be retired in `{self.deprecation_version}`.\n"
|
57
|
+
)
|
58
|
+
|
59
|
+
msg += f"The new behavior can be turned on by setting `flags.{self.flag_name}` to `True` in `dbt_project.yml`.\n"
|
60
|
+
|
61
|
+
if self.deprecation_message:
|
62
|
+
msg += f"{self.deprecation_message}.\n"
|
63
|
+
|
64
|
+
docs_url = self.docs_url or f"https://docs.getdbt.com/search?q={self.flag_name}"
|
65
|
+
msg += f"Visit {docs_url} for more information."
|
66
|
+
|
67
|
+
return warning_tag(msg)
|
68
|
+
|
69
|
+
|
31
70
|
# =======================================================
|
32
71
|
# M - Deps generation
|
33
72
|
# =======================================================
|
dbt_common/events/types_pb2.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
3
3
|
# source: types.proto
|
4
|
-
# Protobuf Python Version:
|
4
|
+
# Protobuf Python Version: 4.25.2
|
5
5
|
"""Generated protocol buffer code."""
|
6
6
|
from google.protobuf import descriptor as _descriptor
|
7
7
|
from google.protobuf import descriptor_pool as _descriptor_pool
|
@@ -15,14 +15,14 @@ _sym_db = _symbol_database.Default()
|
|
15
15
|
from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2
|
16
16
|
|
17
17
|
|
18
|
-
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0btypes.proto\x12\x0bproto_types\x1a\x1fgoogle/protobuf/timestamp.proto\"\x91\x02\n\tEventInfo\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04\x63ode\x18\x02 \x01(\t\x12\x0b\n\x03msg\x18\x03 \x01(\t\x12\r\n\x05level\x18\x04 \x01(\t\x12\x15\n\rinvocation_id\x18\x05 \x01(\t\x12\x0b\n\x03pid\x18\x06 \x01(\x05\x12\x0e\n\x06thread\x18\x07 \x01(\t\x12&\n\x02ts\x18\x08 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x30\n\x05\x65xtra\x18\t \x03(\x0b\x32!.proto_types.EventInfo.ExtraEntry\x12\x10\n\x08\x63\x61tegory\x18\n \x01(\t\x1a,\n\nExtraEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"6\n\x0eGenericMessage\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\"1\n\x11RetryExternalCall\x12\x0f\n\x07\x61ttempt\x18\x01 \x01(\x05\x12\x0b\n\x03max\x18\x02 \x01(\x05\"j\n\x14RetryExternalCallMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12,\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x1e.proto_types.RetryExternalCall\"#\n\x14RecordRetryException\x12\x0b\n\x03\x65xc\x18\x01 \x01(\t\"p\n\x17RecordRetryExceptionMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12/\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32!.proto_types.RecordRetryException\"@\n\x13SystemCouldNotWrite\x12\x0c\n\x04path\x18\x01 \x01(\t\x12\x0e\n\x06reason\x18\x02 \x01(\t\x12\x0b\n\x03\x65xc\x18\x03 \x01(\t\"n\n\x16SystemCouldNotWriteMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12.\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32 .proto_types.SystemCouldNotWrite\"!\n\x12SystemExecutingCmd\x12\x0b\n\x03\x63md\x18\x01 \x03(\t\"l\n\x15SystemExecutingCmdMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12-\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x1f.proto_types.SystemExecutingCmd\"\x1c\n\x0cSystemStdOut\x12\x0c\n\x04\x62msg\x18\x01 \x01(\t\"`\n\x0fSystemStdOutMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12\'\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x19.proto_types.SystemStdOut\"\x1c\n\x0cSystemStdErr\x12\x0c\n\x04\x62msg\x18\x01 \x01(\t\"`\n\x0fSystemStdErrMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12\'\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x19.proto_types.SystemStdErr\",\n\x16SystemReportReturnCode\x12\x12\n\nreturncode\x18\x01 \x01(\x05\"t\n\x19SystemReportReturnCodeMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12\x31\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32#.proto_types.SystemReportReturnCode\"\x19\n\nFormatting\x12\x0b\n\x03msg\x18\x01 \x01(\t\"\\\n\rFormattingMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12%\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x17.proto_types.Formatting\"\x13\n\x04Note\x12\x0b\n\x03msg\x18\x01 \x01(\t\"P\n\x07NoteMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12\x1f\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x11.proto_types.Note\"\x19\n\nPrintEvent\x12\x0b\n\x03msg\x18\x01 \x01(\t\"\\\n\rPrintEventMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12%\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x17.proto_types.PrintEventb\x06proto3')
|
18
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0btypes.proto\x12\x0bproto_types\x1a\x1fgoogle/protobuf/timestamp.proto\"\x91\x02\n\tEventInfo\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04\x63ode\x18\x02 \x01(\t\x12\x0b\n\x03msg\x18\x03 \x01(\t\x12\r\n\x05level\x18\x04 \x01(\t\x12\x15\n\rinvocation_id\x18\x05 \x01(\t\x12\x0b\n\x03pid\x18\x06 \x01(\x05\x12\x0e\n\x06thread\x18\x07 \x01(\t\x12&\n\x02ts\x18\x08 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x30\n\x05\x65xtra\x18\t \x03(\x0b\x32!.proto_types.EventInfo.ExtraEntry\x12\x10\n\x08\x63\x61tegory\x18\n \x01(\t\x1a,\n\nExtraEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"6\n\x0eGenericMessage\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\"\x8e\x01\n\x18\x42\x65haviorDeprecationEvent\x12\x11\n\tflag_name\x18\x01 \x01(\t\x12\x13\n\x0b\x66lag_source\x18\x02 \x01(\t\x12\x1b\n\x13\x64\x65precation_version\x18\x03 \x01(\t\x12\x1b\n\x13\x64\x65precation_message\x18\x04 \x01(\t\x12\x10\n\x08\x64ocs_url\x18\x05 \x01(\t\"x\n\x1b\x42\x65haviorDeprecationEventMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12\x33\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32%.proto_types.BehaviorDeprecationEvent\"1\n\x11RetryExternalCall\x12\x0f\n\x07\x61ttempt\x18\x01 \x01(\x05\x12\x0b\n\x03max\x18\x02 \x01(\x05\"j\n\x14RetryExternalCallMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12,\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x1e.proto_types.RetryExternalCall\"#\n\x14RecordRetryException\x12\x0b\n\x03\x65xc\x18\x01 \x01(\t\"p\n\x17RecordRetryExceptionMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12/\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32!.proto_types.RecordRetryException\"@\n\x13SystemCouldNotWrite\x12\x0c\n\x04path\x18\x01 \x01(\t\x12\x0e\n\x06reason\x18\x02 \x01(\t\x12\x0b\n\x03\x65xc\x18\x03 \x01(\t\"n\n\x16SystemCouldNotWriteMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12.\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32 .proto_types.SystemCouldNotWrite\"!\n\x12SystemExecutingCmd\x12\x0b\n\x03\x63md\x18\x01 \x03(\t\"l\n\x15SystemExecutingCmdMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12-\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x1f.proto_types.SystemExecutingCmd\"\x1c\n\x0cSystemStdOut\x12\x0c\n\x04\x62msg\x18\x01 \x01(\t\"`\n\x0fSystemStdOutMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12\'\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x19.proto_types.SystemStdOut\"\x1c\n\x0cSystemStdErr\x12\x0c\n\x04\x62msg\x18\x01 \x01(\t\"`\n\x0fSystemStdErrMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12\'\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x19.proto_types.SystemStdErr\",\n\x16SystemReportReturnCode\x12\x12\n\nreturncode\x18\x01 \x01(\x05\"t\n\x19SystemReportReturnCodeMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12\x31\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32#.proto_types.SystemReportReturnCode\"\x19\n\nFormatting\x12\x0b\n\x03msg\x18\x01 \x01(\t\"\\\n\rFormattingMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12%\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x17.proto_types.Formatting\"\x13\n\x04Note\x12\x0b\n\x03msg\x18\x01 \x01(\t\"P\n\x07NoteMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12\x1f\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x11.proto_types.Note\"\x19\n\nPrintEvent\x12\x0b\n\x03msg\x18\x01 \x01(\t\"\\\n\rPrintEventMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12%\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x17.proto_types.PrintEventb\x06proto3')
|
19
19
|
|
20
20
|
_globals = globals()
|
21
21
|
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
22
22
|
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'types_pb2', _globals)
|
23
|
-
if
|
24
|
-
DESCRIPTOR.
|
25
|
-
_globals['_EVENTINFO_EXTRAENTRY'].
|
23
|
+
if _descriptor._USE_C_DESCRIPTORS == False:
|
24
|
+
DESCRIPTOR._options = None
|
25
|
+
_globals['_EVENTINFO_EXTRAENTRY']._options = None
|
26
26
|
_globals['_EVENTINFO_EXTRAENTRY']._serialized_options = b'8\001'
|
27
27
|
_globals['_EVENTINFO']._serialized_start=62
|
28
28
|
_globals['_EVENTINFO']._serialized_end=335
|
@@ -30,44 +30,48 @@ if not _descriptor._USE_C_DESCRIPTORS:
|
|
30
30
|
_globals['_EVENTINFO_EXTRAENTRY']._serialized_end=335
|
31
31
|
_globals['_GENERICMESSAGE']._serialized_start=337
|
32
32
|
_globals['_GENERICMESSAGE']._serialized_end=391
|
33
|
-
_globals['
|
34
|
-
_globals['
|
35
|
-
_globals['
|
36
|
-
_globals['
|
37
|
-
_globals['
|
38
|
-
_globals['
|
39
|
-
_globals['
|
40
|
-
_globals['
|
41
|
-
_globals['
|
42
|
-
_globals['
|
43
|
-
_globals['
|
44
|
-
_globals['
|
45
|
-
_globals['
|
46
|
-
_globals['
|
47
|
-
_globals['
|
48
|
-
_globals['
|
49
|
-
_globals['
|
50
|
-
_globals['
|
51
|
-
_globals['
|
52
|
-
_globals['
|
53
|
-
_globals['
|
54
|
-
_globals['
|
55
|
-
_globals['
|
56
|
-
_globals['
|
57
|
-
_globals['
|
58
|
-
_globals['
|
59
|
-
_globals['
|
60
|
-
_globals['
|
61
|
-
_globals['
|
62
|
-
_globals['
|
63
|
-
_globals['
|
64
|
-
_globals['
|
65
|
-
_globals['
|
66
|
-
_globals['
|
67
|
-
_globals['
|
68
|
-
_globals['
|
69
|
-
_globals['
|
70
|
-
_globals['
|
71
|
-
_globals['
|
72
|
-
_globals['
|
33
|
+
_globals['_BEHAVIORDEPRECATIONEVENT']._serialized_start=394
|
34
|
+
_globals['_BEHAVIORDEPRECATIONEVENT']._serialized_end=536
|
35
|
+
_globals['_BEHAVIORDEPRECATIONEVENTMSG']._serialized_start=538
|
36
|
+
_globals['_BEHAVIORDEPRECATIONEVENTMSG']._serialized_end=658
|
37
|
+
_globals['_RETRYEXTERNALCALL']._serialized_start=660
|
38
|
+
_globals['_RETRYEXTERNALCALL']._serialized_end=709
|
39
|
+
_globals['_RETRYEXTERNALCALLMSG']._serialized_start=711
|
40
|
+
_globals['_RETRYEXTERNALCALLMSG']._serialized_end=817
|
41
|
+
_globals['_RECORDRETRYEXCEPTION']._serialized_start=819
|
42
|
+
_globals['_RECORDRETRYEXCEPTION']._serialized_end=854
|
43
|
+
_globals['_RECORDRETRYEXCEPTIONMSG']._serialized_start=856
|
44
|
+
_globals['_RECORDRETRYEXCEPTIONMSG']._serialized_end=968
|
45
|
+
_globals['_SYSTEMCOULDNOTWRITE']._serialized_start=970
|
46
|
+
_globals['_SYSTEMCOULDNOTWRITE']._serialized_end=1034
|
47
|
+
_globals['_SYSTEMCOULDNOTWRITEMSG']._serialized_start=1036
|
48
|
+
_globals['_SYSTEMCOULDNOTWRITEMSG']._serialized_end=1146
|
49
|
+
_globals['_SYSTEMEXECUTINGCMD']._serialized_start=1148
|
50
|
+
_globals['_SYSTEMEXECUTINGCMD']._serialized_end=1181
|
51
|
+
_globals['_SYSTEMEXECUTINGCMDMSG']._serialized_start=1183
|
52
|
+
_globals['_SYSTEMEXECUTINGCMDMSG']._serialized_end=1291
|
53
|
+
_globals['_SYSTEMSTDOUT']._serialized_start=1293
|
54
|
+
_globals['_SYSTEMSTDOUT']._serialized_end=1321
|
55
|
+
_globals['_SYSTEMSTDOUTMSG']._serialized_start=1323
|
56
|
+
_globals['_SYSTEMSTDOUTMSG']._serialized_end=1419
|
57
|
+
_globals['_SYSTEMSTDERR']._serialized_start=1421
|
58
|
+
_globals['_SYSTEMSTDERR']._serialized_end=1449
|
59
|
+
_globals['_SYSTEMSTDERRMSG']._serialized_start=1451
|
60
|
+
_globals['_SYSTEMSTDERRMSG']._serialized_end=1547
|
61
|
+
_globals['_SYSTEMREPORTRETURNCODE']._serialized_start=1549
|
62
|
+
_globals['_SYSTEMREPORTRETURNCODE']._serialized_end=1593
|
63
|
+
_globals['_SYSTEMREPORTRETURNCODEMSG']._serialized_start=1595
|
64
|
+
_globals['_SYSTEMREPORTRETURNCODEMSG']._serialized_end=1711
|
65
|
+
_globals['_FORMATTING']._serialized_start=1713
|
66
|
+
_globals['_FORMATTING']._serialized_end=1738
|
67
|
+
_globals['_FORMATTINGMSG']._serialized_start=1740
|
68
|
+
_globals['_FORMATTINGMSG']._serialized_end=1832
|
69
|
+
_globals['_NOTE']._serialized_start=1834
|
70
|
+
_globals['_NOTE']._serialized_end=1853
|
71
|
+
_globals['_NOTEMSG']._serialized_start=1855
|
72
|
+
_globals['_NOTEMSG']._serialized_end=1935
|
73
|
+
_globals['_PRINTEVENT']._serialized_start=1937
|
74
|
+
_globals['_PRINTEVENT']._serialized_end=1962
|
75
|
+
_globals['_PRINTEVENTMSG']._serialized_start=1964
|
76
|
+
_globals['_PRINTEVENTMSG']._serialized_end=2056
|
73
77
|
# @@protoc_insertion_point(module_scope)
|
dbt_common/exceptions/base.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import builtins
|
2
|
-
from typing import Any, List, Optional
|
2
|
+
from typing import Any, Dict, List, Optional
|
3
3
|
import os
|
4
4
|
|
5
5
|
from dbt_common.constants import SECRET_ENV_PREFIX
|
@@ -23,7 +23,7 @@ class DbtBaseException(Exception):
|
|
23
23
|
CODE = -32000
|
24
24
|
MESSAGE = "Server Error"
|
25
25
|
|
26
|
-
def data(self):
|
26
|
+
def data(self) -> Dict[str, Any]:
|
27
27
|
# if overriding, make sure the result is json-serializable.
|
28
28
|
return {
|
29
29
|
"type": self.__class__.__name__,
|
@@ -32,7 +32,7 @@ class DbtBaseException(Exception):
|
|
32
32
|
|
33
33
|
|
34
34
|
class DbtInternalError(DbtBaseException):
|
35
|
-
def __init__(self, msg: str):
|
35
|
+
def __init__(self, msg: str) -> None:
|
36
36
|
self.stack: List = []
|
37
37
|
self.msg = scrub_secrets(msg, env_secrets())
|
38
38
|
|
@@ -40,7 +40,7 @@ class DbtInternalError(DbtBaseException):
|
|
40
40
|
def type(self) -> str:
|
41
41
|
return "Internal"
|
42
42
|
|
43
|
-
def process_stack(self):
|
43
|
+
def process_stack(self) -> List[str]:
|
44
44
|
lines = []
|
45
45
|
stack = self.stack
|
46
46
|
first = True
|
@@ -81,7 +81,7 @@ class DbtRuntimeError(RuntimeError, DbtBaseException):
|
|
81
81
|
self.node = node
|
82
82
|
self.msg = scrub_secrets(msg, env_secrets())
|
83
83
|
|
84
|
-
def add_node(self, node=None):
|
84
|
+
def add_node(self, node=None) -> None:
|
85
85
|
if node is not None and node is not self.node:
|
86
86
|
if self.node is not None:
|
87
87
|
self.stack.append(self.node)
|
@@ -91,7 +91,7 @@ class DbtRuntimeError(RuntimeError, DbtBaseException):
|
|
91
91
|
def type(self):
|
92
92
|
return "Runtime"
|
93
93
|
|
94
|
-
def node_to_string(self, node: Any):
|
94
|
+
def node_to_string(self, node: Any) -> str:
|
95
95
|
"""Given a node-like object we attempt to create the best identifier we can."""
|
96
96
|
result = ""
|
97
97
|
if hasattr(node, "resource_type"):
|
@@ -103,7 +103,7 @@ class DbtRuntimeError(RuntimeError, DbtBaseException):
|
|
103
103
|
|
104
104
|
return result.strip() if result != "" else "<Unknown>"
|
105
105
|
|
106
|
-
def process_stack(self):
|
106
|
+
def process_stack(self) -> List[str]:
|
107
107
|
lines = []
|
108
108
|
stack = self.stack + [self.node]
|
109
109
|
first = True
|
@@ -122,7 +122,7 @@ class DbtRuntimeError(RuntimeError, DbtBaseException):
|
|
122
122
|
|
123
123
|
return lines
|
124
124
|
|
125
|
-
def validator_error_message(self, exc: builtins.Exception):
|
125
|
+
def validator_error_message(self, exc: builtins.Exception) -> str:
|
126
126
|
"""Given a dbt.dataclass_schema.ValidationError return the relevant parts as a string.
|
127
127
|
|
128
128
|
dbt.dataclass_schema.ValidationError is basically a jsonschema.ValidationError)
|
@@ -132,7 +132,7 @@ class DbtRuntimeError(RuntimeError, DbtBaseException):
|
|
132
132
|
path = "[%s]" % "][".join(map(repr, exc.relative_path))
|
133
133
|
return f"at path {path}: {exc.message}"
|
134
134
|
|
135
|
-
def __str__(self, prefix: str = "! "):
|
135
|
+
def __str__(self, prefix: str = "! ") -> str:
|
136
136
|
node_string = ""
|
137
137
|
|
138
138
|
if self.node is not None:
|
@@ -149,7 +149,7 @@ class DbtRuntimeError(RuntimeError, DbtBaseException):
|
|
149
149
|
|
150
150
|
return lines[0] + "\n" + "\n".join([" " + line for line in lines[1:]])
|
151
151
|
|
152
|
-
def data(self):
|
152
|
+
def data(self) -> Dict[str, Any]:
|
153
153
|
result = DbtBaseException.data(self)
|
154
154
|
if self.node is None:
|
155
155
|
return result
|
@@ -236,7 +236,7 @@ class DbtDatabaseError(DbtRuntimeError):
|
|
236
236
|
CODE = 10003
|
237
237
|
MESSAGE = "Database Error"
|
238
238
|
|
239
|
-
def process_stack(self):
|
239
|
+
def process_stack(self) -> List[str]:
|
240
240
|
lines = []
|
241
241
|
|
242
242
|
if hasattr(self.node, "build_path") and self.node.build_path:
|
@@ -250,7 +250,7 @@ class DbtDatabaseError(DbtRuntimeError):
|
|
250
250
|
|
251
251
|
|
252
252
|
class UnexpectedNullError(DbtDatabaseError):
|
253
|
-
def __init__(self, field_name: str, source):
|
253
|
+
def __init__(self, field_name: str, source) -> None:
|
254
254
|
self.field_name = field_name
|
255
255
|
self.source = source
|
256
256
|
msg = (
|
@@ -268,7 +268,7 @@ class CommandError(DbtRuntimeError):
|
|
268
268
|
self.cmd = cmd_scrubbed
|
269
269
|
self.args = (cwd, cmd_scrubbed, msg)
|
270
270
|
|
271
|
-
def __str__(self):
|
271
|
+
def __str__(self, prefix: str = "! ") -> str:
|
272
272
|
if len(self.cmd) == 0:
|
273
273
|
return f"{self.msg}: No arguments given"
|
274
274
|
return f'{self.msg}: "{self.cmd[0]}"'
|
dbt_common/exceptions/system.py
CHANGED
@@ -26,7 +26,7 @@ class WorkingDirectoryError(CommandError):
|
|
26
26
|
def __init__(self, cwd: str, cmd: List[str], msg: str) -> None:
|
27
27
|
super().__init__(cwd, cmd, msg)
|
28
28
|
|
29
|
-
def __str__(self):
|
29
|
+
def __str__(self, prefix: str = "! ") -> str:
|
30
30
|
return f'{self.msg}: "{self.cwd}"'
|
31
31
|
|
32
32
|
|
@@ -46,5 +46,5 @@ class CommandResultError(CommandError):
|
|
46
46
|
self.stderr = scrub_secrets(stderr.decode("utf-8"), env_secrets())
|
47
47
|
self.args = (cwd, self.cmd, returncode, self.stdout, self.stderr, msg)
|
48
48
|
|
49
|
-
def __str__(self):
|
49
|
+
def __str__(self, prefix: str = "! ") -> str:
|
50
50
|
return f"{self.msg} running: {self.cmd}"
|
dbt_common/invocation.py
CHANGED
dbt_common/semver.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
from dataclasses import dataclass
|
2
2
|
import re
|
3
|
-
from typing import List,
|
3
|
+
from typing import Iterable, List, Union
|
4
4
|
|
5
5
|
import dbt_common.exceptions.base
|
6
6
|
from dbt_common.exceptions import VersionsNotCompatibleError
|
@@ -67,7 +67,7 @@ $
|
|
67
67
|
_VERSION_REGEX = re.compile(_VERSION_REGEX_PAT_STR, re.VERBOSE)
|
68
68
|
|
69
69
|
|
70
|
-
def _cmp(a, b):
|
70
|
+
def _cmp(a, b) -> int:
|
71
71
|
"""Return negative if a<b, zero if a==b, positive if a>b."""
|
72
72
|
return (a > b) - (a < b)
|
73
73
|
|
@@ -123,7 +123,7 @@ class VersionSpecifier(VersionSpecification):
|
|
123
123
|
|
124
124
|
return VersionRange(start=range_start, end=range_end)
|
125
125
|
|
126
|
-
def compare(self, other):
|
126
|
+
def compare(self, other: "VersionSpecifier") -> int:
|
127
127
|
if self.is_unbounded or other.is_unbounded:
|
128
128
|
return 0
|
129
129
|
|
@@ -192,16 +192,16 @@ class VersionSpecifier(VersionSpecification):
|
|
192
192
|
|
193
193
|
return 0
|
194
194
|
|
195
|
-
def __lt__(self, other) -> bool:
|
195
|
+
def __lt__(self, other: "VersionSpecifier") -> bool:
|
196
196
|
return self.compare(other) == -1
|
197
197
|
|
198
|
-
def __gt__(self, other) -> bool:
|
198
|
+
def __gt__(self, other: "VersionSpecifier") -> bool:
|
199
199
|
return self.compare(other) == 1
|
200
200
|
|
201
|
-
def __eq___(self, other) -> bool:
|
201
|
+
def __eq___(self, other: "VersionSpecifier") -> bool:
|
202
202
|
return self.compare(other) == 0
|
203
203
|
|
204
|
-
def __cmp___(self, other):
|
204
|
+
def __cmp___(self, other: "VersionSpecifier") -> int:
|
205
205
|
return self.compare(other)
|
206
206
|
|
207
207
|
@property
|
@@ -221,7 +221,7 @@ class VersionSpecifier(VersionSpecification):
|
|
221
221
|
return self.matcher == Matchers.EXACT
|
222
222
|
|
223
223
|
@classmethod
|
224
|
-
def _nat_cmp(cls, a, b):
|
224
|
+
def _nat_cmp(cls, a, b) -> int:
|
225
225
|
def cmp_prerelease_tag(a, b):
|
226
226
|
if isinstance(a, int) and isinstance(b, int):
|
227
227
|
return _cmp(a, b)
|
@@ -358,27 +358,27 @@ class UnboundedVersionSpecifier(VersionSpecifier):
|
|
358
358
|
matcher=Matchers.EXACT, major=None, minor=None, patch=None, prerelease=None, build=None
|
359
359
|
)
|
360
360
|
|
361
|
-
def __str__(self):
|
361
|
+
def __str__(self) -> str:
|
362
362
|
return "*"
|
363
363
|
|
364
364
|
@property
|
365
|
-
def is_unbounded(self):
|
365
|
+
def is_unbounded(self) -> bool:
|
366
366
|
return True
|
367
367
|
|
368
368
|
@property
|
369
|
-
def is_lower_bound(self):
|
369
|
+
def is_lower_bound(self) -> bool:
|
370
370
|
return False
|
371
371
|
|
372
372
|
@property
|
373
|
-
def is_upper_bound(self):
|
373
|
+
def is_upper_bound(self) -> bool:
|
374
374
|
return False
|
375
375
|
|
376
376
|
@property
|
377
|
-
def is_exact(self):
|
377
|
+
def is_exact(self) -> bool:
|
378
378
|
return False
|
379
379
|
|
380
380
|
|
381
|
-
def reduce_versions(*args):
|
381
|
+
def reduce_versions(*args: Union[VersionSpecifier, VersionRange, str]) -> VersionRange:
|
382
382
|
version_specifiers = []
|
383
383
|
|
384
384
|
for version in args:
|
dbt_common/utils/casting.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# This is useful for proto generated classes in particular, since
|
2
2
|
# the default for protobuf for strings is the empty string, so
|
3
3
|
# Optional[str] types don't work for generated Python classes.
|
4
|
-
from typing import Any, Dict, Optional
|
4
|
+
from typing import Any, Dict, Mapping, Optional
|
5
5
|
|
6
6
|
|
7
7
|
def cast_to_str(string: Optional[str]) -> str:
|
@@ -18,8 +18,9 @@ def cast_to_int(integer: Optional[int]) -> int:
|
|
18
18
|
return integer
|
19
19
|
|
20
20
|
|
21
|
-
def cast_dict_to_dict_of_strings(dct:
|
21
|
+
def cast_dict_to_dict_of_strings(dct: Mapping[Any, Any]) -> Dict[str, str]:
|
22
22
|
new_dct: Dict[str, str] = {}
|
23
|
+
|
23
24
|
for k, v in dct.items():
|
24
25
|
new_dct[str(k)] = str(v)
|
25
26
|
return new_dct
|
dbt_common/utils/connection.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import time
|
2
|
+
from typing import Callable
|
2
3
|
|
3
4
|
from dbt_common.events.types import RecordRetryException, RetryExternalCall
|
4
5
|
from dbt_common.exceptions import ConnectionError
|
@@ -7,7 +8,7 @@ from tarfile import ReadError
|
|
7
8
|
import requests
|
8
9
|
|
9
10
|
|
10
|
-
def connection_exception_retry(fn, max_attempts: int, attempt: int = 0):
|
11
|
+
def connection_exception_retry(fn: Callable, max_attempts: int, attempt: int = 0):
|
11
12
|
"""Handle connection retries gracefully.
|
12
13
|
|
13
14
|
Attempts to run a function that makes an external call, if the call fails
|
dbt_common/utils/jinja.py
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
from typing import Optional
|
2
|
+
|
1
3
|
from dbt_common.exceptions import DbtInternalError
|
2
4
|
|
3
5
|
|
@@ -5,20 +7,20 @@ MACRO_PREFIX = "dbt_macro__"
|
|
5
7
|
DOCS_PREFIX = "dbt_docs__"
|
6
8
|
|
7
9
|
|
8
|
-
def get_dbt_macro_name(name) -> str:
|
10
|
+
def get_dbt_macro_name(name: str) -> str:
|
9
11
|
if name is None:
|
10
12
|
raise DbtInternalError("Got None for a macro name!")
|
11
13
|
return f"{MACRO_PREFIX}{name}"
|
12
14
|
|
13
15
|
|
14
|
-
def get_dbt_docs_name(name) -> str:
|
16
|
+
def get_dbt_docs_name(name: str) -> str:
|
15
17
|
if name is None:
|
16
18
|
raise DbtInternalError("Got None for a doc name!")
|
17
19
|
return f"{DOCS_PREFIX}{name}"
|
18
20
|
|
19
21
|
|
20
22
|
def get_materialization_macro_name(
|
21
|
-
materialization_name, adapter_type=None, with_prefix=True
|
23
|
+
materialization_name: str, adapter_type: Optional[str] = None, with_prefix: bool = True
|
22
24
|
) -> str:
|
23
25
|
if adapter_type is None:
|
24
26
|
adapter_type = "default"
|
@@ -26,10 +28,10 @@ def get_materialization_macro_name(
|
|
26
28
|
return get_dbt_macro_name(name) if with_prefix else name
|
27
29
|
|
28
30
|
|
29
|
-
def get_docs_macro_name(docs_name, with_prefix=True):
|
31
|
+
def get_docs_macro_name(docs_name: str, with_prefix: bool = True) -> str:
|
30
32
|
return get_dbt_docs_name(docs_name) if with_prefix else docs_name
|
31
33
|
|
32
34
|
|
33
|
-
def get_test_macro_name(test_name, with_prefix=True):
|
35
|
+
def get_test_macro_name(test_name: str, with_prefix: bool = True) -> str:
|
34
36
|
name = f"test_{test_name}"
|
35
37
|
return get_dbt_macro_name(name) if with_prefix else name
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: dbt-common
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.8.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
|
@@ -1,33 +1,34 @@
|
|
1
|
-
dbt_common/__about__.py,sha256=
|
1
|
+
dbt_common/__about__.py,sha256=J9Md0egz2m3v0DHzraSTc3Ep1dKM1wRt2RZSVicTmqM,18
|
2
2
|
dbt_common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
+
dbt_common/behavior_flags.py,sha256=fkk9snLsKH4mM4PklQSjjk9heuP7NvB4zFndgQNWM6E,4163
|
3
4
|
dbt_common/constants.py,sha256=-Y5DIL1SDPQWtlCNizXRYxFgbx1D7LaLs1ysamvGMRk,278
|
4
|
-
dbt_common/context.py,sha256=
|
5
|
-
dbt_common/dataclass_schema.py,sha256=
|
5
|
+
dbt_common/context.py,sha256=rk4EYBU4SpDXRhqbSvDTJwojilxPSoaiEdOxkXow_BU,2549
|
6
|
+
dbt_common/dataclass_schema.py,sha256=u2S0dxwxIghv8RMqC91HlWZJVxmsC_844yZQaGyOwdY,5563
|
6
7
|
dbt_common/helper_types.py,sha256=FWJGPmp7Qp2iToHyI4uvhkBbu_d1tl2_oF-obi98_N4,3917
|
7
|
-
dbt_common/invocation.py,sha256=
|
8
|
+
dbt_common/invocation.py,sha256=2ZchIr4Wq7NwtAjjB-mxHP9ITD6-r45jEq4Zooso0gc,210
|
8
9
|
dbt_common/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
10
|
dbt_common/record.py,sha256=og-9SZhRINqW6jnqLdf3CTVKvUPdKldi52oFaa2-QRE,12658
|
10
|
-
dbt_common/semver.py,sha256=
|
11
|
+
dbt_common/semver.py,sha256=NNG0CVJosfwSVQ8WKKGtK_qzinbEy-OEn_jih36Y0Co,14364
|
11
12
|
dbt_common/tests.py,sha256=6lC_JuRtoYO6cbAF8-R5aTM4HtQiM_EH8X5m_97duGY,315
|
12
13
|
dbt_common/ui.py,sha256=rc2TEM29raBFc_LXcg901pMDD07C2ohwp9qzkE-7pBY,2567
|
13
14
|
dbt_common/clients/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
14
15
|
dbt_common/clients/_jinja_blocks.py,sha256=xoJK9Y0F93U2PKfT_3SJbBopCGYCtl7LiwKuylXnrEE,12947
|
15
|
-
dbt_common/clients/agate_helper.py,sha256=
|
16
|
-
dbt_common/clients/jinja.py,sha256=
|
17
|
-
dbt_common/clients/system.py,sha256=
|
16
|
+
dbt_common/clients/agate_helper.py,sha256=anKKgKV5PSnFRuFeBwRMdHK3JCaQoUqB2ZXHD0su0Wo,9123
|
17
|
+
dbt_common/clients/jinja.py,sha256=yB7fv_Y5LKnj-3BKl3KCFDQYSFEEvn5YCyyu0vBsFR8,18495
|
18
|
+
dbt_common/clients/system.py,sha256=aoUBtOuXVmkOyj6IhhJ3Y4a7JFzPO2F_zKyOtz3xy44,23932
|
18
19
|
dbt_common/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
19
20
|
dbt_common/contracts/constraints.py,sha256=_f1q3Rkcg2UwA7zI5XBbUMXnPUg6pw17UC7l1HyhyQM,1352
|
20
21
|
dbt_common/contracts/metadata.py,sha256=K_M06Rue0wmrQhFP_mq3uvQszq10CIt93oGiAVgbRfE,1293
|
21
|
-
dbt_common/contracts/util.py,sha256=
|
22
|
+
dbt_common/contracts/util.py,sha256=_-vtcI6ZGmYVgrlxOw4M3YuH34Ncx-oKdKg7TV0pV78,916
|
22
23
|
dbt_common/contracts/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
23
|
-
dbt_common/contracts/config/base.py,sha256=
|
24
|
+
dbt_common/contracts/config/base.py,sha256=JR9a7FdboXugexqXmab82TabKyRoRW8OPGn2_vVlS6g,8492
|
24
25
|
dbt_common/contracts/config/materialization.py,sha256=rahC72qZ0-jB8oPwxyPooZXc5NJ-smg74g2HnGOMj34,256
|
25
26
|
dbt_common/contracts/config/metadata.py,sha256=X47-tEA8q2ZfSMcYv0godUwTSVjt8NI77tD4NqdgM0c,1877
|
26
27
|
dbt_common/contracts/config/properties.py,sha256=gWt6xsP4rVOqRKhmagiUhWnDynzD9mykfMYMTviwpEU,2281
|
27
28
|
dbt_common/events/README.md,sha256=CSwVajoxCAqOug2UCnXldH1EUK7Kjf3rcq7z9ACjrss,3023
|
28
29
|
dbt_common/events/__init__.py,sha256=av08vfpxo0ek7PqZNtMxY8FODJ3xwph4ehRxgInx4LA,383
|
29
30
|
dbt_common/events/base_types.py,sha256=1l4Yx8zuma7jABB1fcPvL20ltpQ46w0mlYxn48kHykY,5415
|
30
|
-
dbt_common/events/contextvars.py,sha256=
|
31
|
+
dbt_common/events/contextvars.py,sha256=EIs1P6NrJzx_IAV17x5cVqOAS4Lqbu6oc0etHtWCJOo,3097
|
31
32
|
dbt_common/events/event_handler.py,sha256=jfi0PyqIOGnXCG9HEa0VIVULqNvXs1RYmAg0b50ChQs,1385
|
32
33
|
dbt_common/events/event_manager.py,sha256=IIUwSyt_RcBbUI_iE5mnpmZt2uW7lG49RXOWz2VlUv0,2300
|
33
34
|
dbt_common/events/event_manager_client.py,sha256=VKlIYJPcexmDKnidkyrs8BIuNZ1_CwDFGz-gBM2SAvo,1193
|
@@ -36,27 +37,27 @@ dbt_common/events/functions.py,sha256=K-R-FBTeO03U51gtMBu1EUcNsIAsgw_e5spWxLJ44V
|
|
36
37
|
dbt_common/events/helpers.py,sha256=CfsWwNDjsLJkPIgOtAfuLEnZ3rGUKeYsH8aDtCW12OA,410
|
37
38
|
dbt_common/events/interfaces.py,sha256=hEDeDoB0FW2RYHVZBG7gebEt_mUVBzkn1yPubpaxs-s,147
|
38
39
|
dbt_common/events/logger.py,sha256=mAUNLZlIIOl3T2u7KOe8FF_deTNNe1CRJqmkPw4YH1U,6728
|
39
|
-
dbt_common/events/types.proto,sha256=
|
40
|
-
dbt_common/events/types.py,sha256=
|
41
|
-
dbt_common/events/types_pb2.py,sha256=
|
40
|
+
dbt_common/events/types.proto,sha256=VflTmP9HUsatIi7xC3GXk2eJHsrS5041m5qpA7idU6c,2335
|
41
|
+
dbt_common/events/types.py,sha256=aQ9TSsOyVBq2LMdMQQVktGww0qzH4PpR4AHArMQWtT8,5049
|
42
|
+
dbt_common/events/types_pb2.py,sha256=0kIhc1xWqhF3DtJhaAdN_8AjxzxkFcVzE53Dd5mdS5Q,7277
|
42
43
|
dbt_common/exceptions/__init__.py,sha256=X_Uw7BxOzXev_9JMYfs5Cm-_i_Qf2PJim8_-dDJI7Y8,361
|
43
|
-
dbt_common/exceptions/base.py,sha256=
|
44
|
+
dbt_common/exceptions/base.py,sha256=d6lsA8sLqR6_BERowm91Mrs1ZwrEOeT8WQKWg4nPSPA,7750
|
44
45
|
dbt_common/exceptions/cache.py,sha256=0z4fBcdNZMAR41YbPRo2GN0__xAMaYs8Uc-t3hjmVio,2532
|
45
46
|
dbt_common/exceptions/connection.py,sha256=rXLJXUdLhyXP3CUUyiqWN2DDO5-0Pn1ChX3OIR7pxKk,176
|
46
47
|
dbt_common/exceptions/contracts.py,sha256=i2PKRqda1Pq_Sro9FA22W7FTGklhBAGl6__nimR5_qI,527
|
47
48
|
dbt_common/exceptions/events.py,sha256=j83szhbqmK3ITZR_xwA2dYTNaPcGF_lN_kQar6dQgjQ,317
|
48
49
|
dbt_common/exceptions/jinja.py,sha256=PzVUB1MFf8x81bQHTwFIGw3PyrGZzWYw04eotI4CqtI,3124
|
49
50
|
dbt_common/exceptions/macros.py,sha256=2nujJrtpWHnhBwcyhcOmeVaEzILh3W9gtyP6vVpkA0o,3301
|
50
|
-
dbt_common/exceptions/system.py,sha256=
|
51
|
+
dbt_common/exceptions/system.py,sha256=scoKnSx2frTFCrfk2cH0g-z3MuzE-SEBXFC9P-jzB2s,1603
|
51
52
|
dbt_common/utils/__init__.py,sha256=8PNb_A9zm2YfYMa0GsM-pAyJy3Iu0FUtWKvCs8kFhD0,549
|
52
|
-
dbt_common/utils/casting.py,sha256=
|
53
|
-
dbt_common/utils/connection.py,sha256=
|
53
|
+
dbt_common/utils/casting.py,sha256=xMulzzTrIQvw65UC9wr9oUWw5xp-BcUKtHaE8dldfII,679
|
54
|
+
dbt_common/utils/connection.py,sha256=gyEdWPG7NauZqMX9ZzbglaaB8itEpdwtn-0s_Zw79rk,1411
|
54
55
|
dbt_common/utils/dict.py,sha256=unI-kJs2yvw7ic2U71-6H8koVRknkb0jCk7W_FCq6_I,4014
|
55
56
|
dbt_common/utils/encoding.py,sha256=6_kSY2FvGNYMg7oX7PrbvVioieydih3Kl7Ii802LaHI,1705
|
56
57
|
dbt_common/utils/executor.py,sha256=pNY0UbPlwQmTE69Vt_Rj91YGCIOEaqeYU3CjAds0T70,2454
|
57
58
|
dbt_common/utils/formatting.py,sha256=JUn5rzJ-uajs9wPCN0-f2iRFY1pOJF5YjTD9dERuLoc,165
|
58
|
-
dbt_common/utils/jinja.py,sha256=
|
59
|
-
dbt_common-1.
|
60
|
-
dbt_common-1.
|
61
|
-
dbt_common-1.
|
62
|
-
dbt_common-1.
|
59
|
+
dbt_common/utils/jinja.py,sha256=JXgNmJArGGy0h7qkbNLA3zaEQmoF1CxsNBYTlIwFXDw,1101
|
60
|
+
dbt_common-1.8.0.dist-info/METADATA,sha256=9YS6_dZQSWe_FuiBUu-lYqVdhptGjdU-na84EExK72g,5298
|
61
|
+
dbt_common-1.8.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
62
|
+
dbt_common-1.8.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
63
|
+
dbt_common-1.8.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|