dbt-bouncer 1.26.0__py3-none-any.whl → 1.27.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_bouncer/runner.py CHANGED
@@ -14,6 +14,7 @@ from tabulate import tabulate
14
14
  from dbt_bouncer.utils import (
15
15
  create_github_comment_file,
16
16
  get_check_objects,
17
+ get_nested_value,
17
18
  resource_in_path,
18
19
  )
19
20
 
@@ -114,14 +115,36 @@ def runner(
114
115
  iterate_value = next(iter(iterate_over_value))
115
116
  for i in locals()[f"{iterate_value}s"]:
116
117
  check_i = copy.deepcopy(check)
118
+ if iterate_value in ["model", "semantic_model", "snapshot", "source"]:
119
+ try:
120
+ d = getattr(i, iterate_value).config.meta
121
+ except Exception:
122
+ d = getattr(i, iterate_value).meta
123
+ elif iterate_value in ["catalog_node", "run_result"]:
124
+ d = {}
125
+ elif iterate_value in ["macro"]:
126
+ d = i.meta
127
+ else:
128
+ try:
129
+ d = i.config.meta
130
+ except Exception:
131
+ d = i.meta
132
+ meta_config = get_nested_value(
133
+ d,
134
+ ["dbt-bouncer", "skip_checks"],
135
+ [],
136
+ )
117
137
  if resource_in_path(check_i, i) and (
118
- iterate_over_value != {"model"}
119
- or (
120
- iterate_over_value == {"model"}
121
- and check_i.materialization == i.model.config.materialized
122
- if check_i.materialization is not None
123
- else True
138
+ (
139
+ iterate_over_value != {"model"}
140
+ or (
141
+ iterate_over_value == {"model"}
142
+ and check_i.materialization == i.model.config.materialized
143
+ if check_i.materialization is not None
144
+ else True
145
+ )
124
146
  )
147
+ and (check_i.name not in meta_config if meta_config != [] else True)
125
148
  ):
126
149
  check_run_id = (
127
150
  f"{check_i.name}:{check_i.index}:{i.unique_id.split('.')[-1]}"
dbt_bouncer/utils.py CHANGED
@@ -9,7 +9,7 @@ import re
9
9
  import sys
10
10
  from functools import lru_cache
11
11
  from pathlib import Path
12
- from typing import TYPE_CHECKING, Any, List, Mapping, Type
12
+ from typing import TYPE_CHECKING, Any, Dict, List, Mapping, Optional, Type
13
13
 
14
14
  import click
15
15
  import yaml
@@ -58,6 +58,39 @@ def create_github_comment_file(
58
58
  f.write(md_formatted_comment)
59
59
 
60
60
 
61
+ def get_nested_value(
62
+ d: Dict[str, Any], keys: List[str], default: Optional[Any] = None
63
+ ) -> Any:
64
+ """Retrieve a value from a nested dictionary using a list of keys.
65
+
66
+ This function safely traverses a dictionary structure, allowing access to
67
+ deeply nested values. If any key in the `keys` list does not exist at
68
+ its respective level, the function returns the specified default value.
69
+
70
+ Args:
71
+ d: The dictionary to traverse.
72
+ keys: A list of strings representing the sequence of keys to follow
73
+ to reach the desired nested value.
74
+ default: The value to return if any key in the `keys` list is not
75
+ found at its corresponding level, or if an intermediate
76
+ value is not a dictionary. Defaults to None.
77
+
78
+ Returns:
79
+ The value found at the specified nested path, or the `default` value
80
+ if any part of the path is invalid or not found.
81
+
82
+ """
83
+ current_level = d
84
+ for key in keys:
85
+ if isinstance(current_level, dict):
86
+ current_level = current_level.get(key, default) # type: ignore[assignment]
87
+ if current_level is default and key != keys[-1]:
88
+ return default
89
+ else:
90
+ return default
91
+ return current_level
92
+
93
+
61
94
  def resource_in_path(check, resource) -> bool:
62
95
  """Validate that a check is applicable to a specific resource path.
63
96
 
dbt_bouncer/version.py CHANGED
@@ -5,4 +5,4 @@ def version() -> str:
5
5
  str: The version of `dbt-bouncer`.
6
6
 
7
7
  """
8
- return "1.26.0"
8
+ return "1.27.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: dbt-bouncer
3
- Version: 1.26.0
3
+ Version: 1.27.0
4
4
  Summary: Configure and enforce conventions for your dbt project.
5
5
  License: MIT
6
6
  Keywords: python,cli,dbt,CI/CD
@@ -25,11 +25,11 @@ dbt_bouncer/config_file_parser.py,sha256=gq7fINTmLFVWR4todXkPd_dnh0-9vnM3jHYtgk1
25
25
  dbt_bouncer/config_file_validator.py,sha256=lEPv6AfXmUGwuSpl4GzZ4LB0yId7yqjeB2raWfuBs3s,10893
26
26
  dbt_bouncer/logger.py,sha256=qkwB-SVUE4YUUp-MtmbcDPUX7t3zdniQL5Linuomr94,1804
27
27
  dbt_bouncer/main.py,sha256=n-jOsKlDwAlB2uF__J_DtkU8BC7CqeKMOU_f8axB1fo,6433
28
- dbt_bouncer/runner.py,sha256=67axg-1_rymjAzWL8P5TZ-ig_4MBzbEuh5V7p6htGpk,9666
29
- dbt_bouncer/utils.py,sha256=ppPQabXl5ucCEaaPuQ3ghEojSW3GYqBay0gIgcyeYEU,8596
30
- dbt_bouncer/version.py,sha256=IbXcJLjsdz5zDK4G-XEpYrLMDVwuFSNV3mu99Ti_FMU,149
31
- dbt_bouncer-1.26.0.dist-info/LICENSE,sha256=gGXp4VL__ZWlTWhXHRjWJmkxl5X9UJ7L7n1dr2WlfsY,1074
32
- dbt_bouncer-1.26.0.dist-info/METADATA,sha256=1rAQzx4gIaPtJMYVDBorcdos5JoNc7kuMqOp_q5Sm3k,4606
33
- dbt_bouncer-1.26.0.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
34
- dbt_bouncer-1.26.0.dist-info/entry_points.txt,sha256=jEl2FZDm4gO8u4x9m8qS0zMf9Fk2FAwLfI4N4sreGxI,52
35
- dbt_bouncer-1.26.0.dist-info/RECORD,,
28
+ dbt_bouncer/runner.py,sha256=fdgpOUS8ckS_rZbklOUqFSxmD6I8WYRhQU09HZI0Ghs,10628
29
+ dbt_bouncer/utils.py,sha256=-jZjc6R0tjHWqpTjgHIb7Ej6Cqwdbchbl7L8IB4mo1I,9890
30
+ dbt_bouncer/version.py,sha256=2bejzqKgjlauIGKm2mW4JgMWiYcxmHAYd1zo_ksdiKA,149
31
+ dbt_bouncer-1.27.0.dist-info/LICENSE,sha256=gGXp4VL__ZWlTWhXHRjWJmkxl5X9UJ7L7n1dr2WlfsY,1074
32
+ dbt_bouncer-1.27.0.dist-info/METADATA,sha256=y-Y-EPyj1OROYQicNUKqf5pXOdolmsgHPvVGWRpeg9k,4606
33
+ dbt_bouncer-1.27.0.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
34
+ dbt_bouncer-1.27.0.dist-info/entry_points.txt,sha256=jEl2FZDm4gO8u4x9m8qS0zMf9Fk2FAwLfI4N4sreGxI,52
35
+ dbt_bouncer-1.27.0.dist-info/RECORD,,