dbt-common 1.14.0__tar.gz → 1.16.0__tar.gz

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.
Files changed (108) hide show
  1. {dbt_common-1.14.0 → dbt_common-1.16.0}/CHANGELOG.md +27 -0
  2. {dbt_common-1.14.0 → dbt_common-1.16.0}/PKG-INFO +5 -6
  3. {dbt_common-1.14.0 → dbt_common-1.16.0}/README.md +1 -3
  4. dbt_common-1.16.0/dbt_common/__about__.py +1 -0
  5. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/clients/jinja.py +66 -0
  6. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/context.py +14 -0
  7. dbt_common-1.16.0/dbt_common/invocation.py +19 -0
  8. dbt_common-1.16.0/dbt_common/record.py +589 -0
  9. {dbt_common-1.14.0 → dbt_common-1.16.0}/docs/guides/record_replay.md +2 -2
  10. dbt_common-1.14.0/dbt_common/__about__.py +0 -1
  11. dbt_common-1.14.0/dbt_common/invocation.py +0 -12
  12. dbt_common-1.14.0/dbt_common/record.py +0 -356
  13. {dbt_common-1.14.0 → dbt_common-1.16.0}/.gitignore +0 -0
  14. {dbt_common-1.14.0 → dbt_common-1.16.0}/LICENSE +0 -0
  15. {dbt_common-1.14.0 → dbt_common-1.16.0}/codecov.yml +0 -0
  16. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/__init__.py +0 -0
  17. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/behavior_flags.py +0 -0
  18. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/clients/__init__.py +0 -0
  19. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/clients/_jinja_blocks.py +0 -0
  20. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/clients/agate_helper.py +0 -0
  21. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/clients/system.py +0 -0
  22. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/constants.py +0 -0
  23. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/contracts/__init__.py +0 -0
  24. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/contracts/config/__init__.py +0 -0
  25. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/contracts/config/base.py +0 -0
  26. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/contracts/config/materialization.py +0 -0
  27. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/contracts/config/metadata.py +0 -0
  28. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/contracts/config/properties.py +0 -0
  29. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/contracts/constraints.py +0 -0
  30. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/contracts/metadata.py +0 -0
  31. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/contracts/util.py +0 -0
  32. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/dataclass_schema.py +0 -0
  33. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/events/README.md +0 -0
  34. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/events/__init__.py +0 -0
  35. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/events/base_types.py +0 -0
  36. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/events/contextvars.py +0 -0
  37. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/events/event_handler.py +0 -0
  38. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/events/event_manager.py +0 -0
  39. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/events/event_manager_client.py +0 -0
  40. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/events/format.py +0 -0
  41. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/events/functions.py +0 -0
  42. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/events/helpers.py +0 -0
  43. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/events/interfaces.py +0 -0
  44. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/events/logger.py +0 -0
  45. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/events/types.proto +0 -0
  46. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/events/types.py +0 -0
  47. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/events/types_pb2.py +0 -0
  48. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/exceptions/__init__.py +0 -0
  49. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/exceptions/base.py +0 -0
  50. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/exceptions/cache.py +0 -0
  51. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/exceptions/connection.py +0 -0
  52. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/exceptions/contracts.py +0 -0
  53. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/exceptions/events.py +0 -0
  54. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/exceptions/jinja.py +0 -0
  55. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/exceptions/macros.py +0 -0
  56. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/exceptions/system.py +0 -0
  57. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/helper_types.py +0 -0
  58. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/py.typed +0 -0
  59. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/semver.py +0 -0
  60. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/tests.py +0 -0
  61. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/ui.py +0 -0
  62. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/utils/__init__.py +0 -0
  63. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/utils/casting.py +0 -0
  64. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/utils/connection.py +0 -0
  65. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/utils/dict.py +0 -0
  66. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/utils/encoding.py +0 -0
  67. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/utils/executor.py +0 -0
  68. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/utils/formatting.py +0 -0
  69. {dbt_common-1.14.0 → dbt_common-1.16.0}/dbt_common/utils/jinja.py +0 -0
  70. {dbt_common-1.14.0 → dbt_common-1.16.0}/docs/README.md +0 -0
  71. {dbt_common-1.14.0 → dbt_common-1.16.0}/docs/arch/adr-0001-build-tooling.md +0 -0
  72. {dbt_common-1.14.0 → dbt_common-1.16.0}/pyproject.toml +0 -0
  73. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/agate/__init__.pyi +0 -0
  74. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/agate/data_types.pyi +0 -0
  75. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/colorama/__init__.pyi +0 -0
  76. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/isodate/__init__.pyi +0 -0
  77. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/__init__.pyi +0 -0
  78. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/config.pyi +0 -0
  79. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/core/__init__.pyi +0 -0
  80. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/core/const.pyi +0 -0
  81. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/core/helpers.pyi +0 -0
  82. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/core/meta/__init__.pyi +0 -0
  83. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/core/meta/code/__init__.pyi +0 -0
  84. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/core/meta/code/builder.pyi +0 -0
  85. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/core/meta/code/lines.pyi +0 -0
  86. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/core/meta/helpers.pyi +0 -0
  87. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/core/meta/mixin.pyi +0 -0
  88. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/core/meta/types/__init__.pyi +0 -0
  89. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/core/meta/types/common.pyi +0 -0
  90. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/core/meta/types/pack.pyi +0 -0
  91. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/core/meta/types/unpack.pyi +0 -0
  92. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/dialect.pyi +0 -0
  93. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/exceptions.pyi +0 -0
  94. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/helper.pyi +0 -0
  95. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/jsonschema/__init__.pyi +0 -0
  96. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/jsonschema/annotations.pyi +0 -0
  97. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/jsonschema/builder.pyi +0 -0
  98. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/jsonschema/dialects.pyi +0 -0
  99. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/jsonschema/models.pyi +0 -0
  100. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/jsonschema/schema.pyi +0 -0
  101. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/mixins/__init__.pyi +0 -0
  102. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/mixins/dict.pyi +0 -0
  103. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/mixins/json.pyi +0 -0
  104. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/mixins/msgpack.pyi +0 -0
  105. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/mixins/orjson.pyi +0 -0
  106. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/mixins/toml.pyi +0 -0
  107. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/mixins/yaml.pyi +0 -0
  108. {dbt_common-1.14.0 → dbt_common-1.16.0}/third-party-stubs/mashumaro/types.pyi +0 -0
@@ -5,6 +5,33 @@
5
5
  - "Breaking changes" listed under a version may require action from end users or external maintainers when upgrading to that version.
6
6
  - Do not edit this file directly. This file is auto-generated using [changie](https://github.com/miniscruff/changie). For details on how to document a change, see [the contributing guide](https://github.com/dbt-labs/dbt-common/blob/main/CONTRIBUTING.md#adding-changelog-entry)
7
7
 
8
+ ## dbt-common 1.16.0 - March 18, 2025
9
+
10
+ ### Features
11
+
12
+ - Add sequence number to record/replay records and add new invocation context accessor ([#251](https://github.com/dbt-labs/dbt-common/issues/251))
13
+
14
+
15
+
16
+ ## dbt-common 1.15.0 - February 14, 2025
17
+
18
+ ### Features
19
+
20
+ - Add syntax support for types on macro parameters. ([#229](https://github.com/dbt-labs/dbt-common/issues/229))
21
+ - Add '@auto_record_function' for less verbose record/replay annotaitons ([#240](https://github.com/dbt-labs/dbt-common/issues/240))
22
+ - Add override and serialization capabilities to record/replay ([#241](https://github.com/dbt-labs/dbt-common/issues/241))
23
+ - Add "invocation_started_at" global field ([#245](https://github.com/dbt-labs/dbt-common/issues/245))
24
+
25
+ ### Fixes
26
+
27
+ - Refine support for classmethods in record/replay ([#243](https://github.com/dbt-labs/dbt-common/issues/243))
28
+
29
+ ## dbt-common 1.14.0 - December 4, 2024
30
+
31
+ ### Fixes
32
+
33
+ - Generic exception handling during jinja compilation ([#225](https://github.com/dbt-labs/dbt-common/issues/225))
34
+
8
35
  ## dbt-common 1.13.0 - November 19, 2024
9
36
 
10
37
  ### Features
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: dbt-common
3
- Version: 1.14.0
3
+ Version: 1.16.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,7 +8,8 @@ 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: Apache-2.0
11
+ License-Expression: Apache-2.0
12
+ License-File: LICENSE
12
13
  Classifier: Development Status :: 2 - Pre-Alpha
13
14
  Classifier: License :: OSI Approved :: Apache Software License
14
15
  Classifier: Operating System :: MacOS :: MacOS X
@@ -65,9 +66,7 @@ The shared common utilities for dbt-core and adapter implementations use
65
66
 
66
67
  ### Releasing dbt-common
67
68
  To release a new version of dbt-common to pypi, you'll need to:
68
- 1. Bump the `version` in [dbt_common_/__about__.py](https://github.com/dbt-labs/dbt-common/blob/main/dbt_common/__about__.py)
69
- 2. Run the [release workflow](https://github.com/dbt-labs/dbt-common/actions/workflows/release.yml) to test pypi and confirm a successful test release in: https://test.pypi.org/project/dbt-common/
70
- 3. Run the [release workflow](https://github.com/dbt-labs/dbt-common/actions/workflows/release.yml) to prod pypi and confirm a successful release in: https://pypi.org/project/dbt-common/
69
+ 1. Run the [release workflow](https://github.com/dbt-labs/dbt-common/actions/workflows/release.yml) to bump the version, generate changelogs and release to pypi
71
70
  4. Bump the version of `dbt-common` in `dbt-core` and `dbt-adapters` if you're releasing a new major version or a pre-release:
72
71
  * `dbt-core`: [setup.py](https://github.com/dbt-labs/dbt-core/blob/main/core/setup.py)
73
72
  * `dbt-adapters`: [pyproject.toml](https://github.com/dbt-labs/dbt-adapters/blob/main/pyproject.toml)
@@ -4,9 +4,7 @@ The shared common utilities for dbt-core and adapter implementations use
4
4
 
5
5
  ### Releasing dbt-common
6
6
  To release a new version of dbt-common to pypi, you'll need to:
7
- 1. Bump the `version` in [dbt_common_/__about__.py](https://github.com/dbt-labs/dbt-common/blob/main/dbt_common/__about__.py)
8
- 2. Run the [release workflow](https://github.com/dbt-labs/dbt-common/actions/workflows/release.yml) to test pypi and confirm a successful test release in: https://test.pypi.org/project/dbt-common/
9
- 3. Run the [release workflow](https://github.com/dbt-labs/dbt-common/actions/workflows/release.yml) to prod pypi and confirm a successful release in: https://pypi.org/project/dbt-common/
7
+ 1. Run the [release workflow](https://github.com/dbt-labs/dbt-common/actions/workflows/release.yml) to bump the version, generate changelogs and release to pypi
10
8
  4. Bump the version of `dbt-common` in `dbt-core` and `dbt-adapters` if you're releasing a new major version or a pre-release:
11
9
  * `dbt-core`: [setup.py](https://github.com/dbt-labs/dbt-core/blob/main/core/setup.py)
12
10
  * `dbt-adapters`: [pyproject.toml](https://github.com/dbt-labs/dbt-adapters/blob/main/pyproject.toml)
@@ -0,0 +1 @@
1
+ version = "1.16.0"
@@ -1,4 +1,5 @@
1
1
  import codecs
2
+ import dataclasses
2
3
  import linecache
3
4
  import os
4
5
  import tempfile
@@ -90,6 +91,12 @@ def _linecache_inject(source: str, write: bool) -> str:
90
91
  return filename
91
92
 
92
93
 
94
+ @dataclasses.dataclass
95
+ class MacroType:
96
+ name: str
97
+ type_params: List["MacroType"] = dataclasses.field(default_factory=list)
98
+
99
+
93
100
  class MacroFuzzParser(jinja2.parser.Parser):
94
101
  def parse_macro(self) -> jinja2.nodes.Macro:
95
102
  node = jinja2.nodes.Macro(lineno=next(self.stream).lineno)
@@ -103,6 +110,65 @@ class MacroFuzzParser(jinja2.parser.Parser):
103
110
  node.body = self.parse_statements(("name:endmacro",), drop_needle=True)
104
111
  return node
105
112
 
113
+ def parse_signature(self, node: Union[jinja2.nodes.Macro, jinja2.nodes.CallBlock]) -> None:
114
+ """Overrides the default jinja Parser.parse_signature method, modifying
115
+ the original implementation to allow macros to have typed parameters."""
116
+
117
+ # Jinja does not support extending its node types, such as Macro, so
118
+ # at least while typed macros are experimental, we will patch the
119
+ # information onto the existing types.
120
+ setattr(node, "arg_types", [])
121
+ setattr(node, "has_type_annotations", False)
122
+
123
+ args = node.args = [] # type: ignore
124
+ defaults = node.defaults = [] # type: ignore
125
+
126
+ self.stream.expect("lparen")
127
+ while self.stream.current.type != "rparen":
128
+ if args:
129
+ self.stream.expect("comma")
130
+
131
+ arg = self.parse_assign_target(name_only=True)
132
+ arg.set_ctx("param")
133
+
134
+ type_name: Optional[str]
135
+ if self.stream.skip_if("colon"):
136
+ node.has_type_annotations = True # type: ignore
137
+ type_name = self.parse_type_name()
138
+ else:
139
+ type_name = ""
140
+
141
+ node.arg_types.append(type_name) # type: ignore
142
+
143
+ if self.stream.skip_if("assign"):
144
+ defaults.append(self.parse_expression())
145
+ elif defaults:
146
+ self.fail("non-default argument follows default argument")
147
+
148
+ args.append(arg)
149
+ self.stream.expect("rparen")
150
+
151
+ def parse_type_name(self) -> MacroType:
152
+ # NOTE: Types syntax is validated here, but not whether type names
153
+ # are valid or have correct parameters.
154
+
155
+ # A type name should consist of a name (i.e. 'Dict')...
156
+ type_name = self.stream.expect("name").value
157
+ type = MacroType(type_name)
158
+
159
+ # ..and an optional comma-delimited list of type parameters
160
+ # as in the type declaration 'Dict[str, str]'
161
+ if self.stream.skip_if("lbracket"):
162
+ while self.stream.current.type != "rbracket":
163
+ if type.type_params:
164
+ self.stream.expect("comma")
165
+ param_type = self.parse_type_name()
166
+ type.type_params.append(param_type)
167
+
168
+ self.stream.expect("rbracket")
169
+
170
+ return type
171
+
106
172
 
107
173
  class MacroFuzzEnvironment(jinja2.sandbox.SandboxedEnvironment):
108
174
  def _parse(
@@ -39,9 +39,16 @@ class InvocationContext:
39
39
  else:
40
40
  self._env = env_public
41
41
 
42
+ self.name = "unset"
42
43
  self._env_secrets: Optional[List[str]] = None
43
44
  self._env_private = env_private
44
45
  self.recorder: Optional[Recorder] = None
46
+
47
+ # If set to True later, this flag will prevent dbt from creating a new
48
+ # invocation context for every invocation, which is useful for testing
49
+ # scenarios.
50
+ self.do_not_reset = False
51
+
45
52
  # This class will also eventually manage the invocation_id, flags, event manager, etc.
46
53
 
47
54
  @property
@@ -84,3 +91,10 @@ def get_invocation_context() -> InvocationContext:
84
91
  invocation_var = reliably_get_invocation_var()
85
92
  ctx = invocation_var.get()
86
93
  return ctx
94
+
95
+
96
+ def try_get_invocation_context() -> Optional[InvocationContext]:
97
+ try:
98
+ return get_invocation_context()
99
+ except Exception:
100
+ return None
@@ -0,0 +1,19 @@
1
+ import uuid
2
+ from datetime import datetime
3
+
4
+ _INVOCATION_ID = str(uuid.uuid4())
5
+ _INVOCATION_STARTED_AT = datetime.utcnow()
6
+
7
+
8
+ def get_invocation_id() -> str:
9
+ return _INVOCATION_ID
10
+
11
+
12
+ def get_invocation_started_at() -> datetime:
13
+ return _INVOCATION_STARTED_AT
14
+
15
+
16
+ def reset_invocation_id() -> None:
17
+ global _INVOCATION_ID, _INVOCATION_STARTED_AT
18
+ _INVOCATION_ID = str(uuid.uuid4())
19
+ _INVOCATION_STARTED_AT = datetime.utcnow()