Skip to content

Commit 3339f62

Browse files
committed
Format
1 parent 6aa2032 commit 3339f62

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/databricks/labs/lsql/dashboards.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def _parse_widget_metadata(self, path: Path, widget: Widget) -> WidgetMetadata:
151151
logger.warning(f"Parsing {path}: {e}")
152152
return fallback_metadata
153153

154-
if len(parsed_query.comments) == 0:
154+
if parsed_query.comments is None or len(parsed_query.comments) == 0:
155155
return fallback_metadata
156156

157157
first_comment = parsed_query.comments[0]

tests/unit/test_dashboards.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ def test_dashboard_handles_incorrect_query_header(tmp_path, caplog):
332332
ws = create_autospec(WorkspaceClient)
333333

334334
# Typo is on purpose
335-
query = f"-- --widh 6 --height 3 \nSELECT 82917019218921 AS big_number_needs_big_widget"
335+
query = "-- --widh 6 --height 3 \nSELECT 82917019218921 AS big_number_needs_big_widget"
336336
with (tmp_path / "counter.sql").open("w") as f:
337337
f.write(query)
338338

@@ -349,14 +349,14 @@ def test_dashboard_handles_incorrect_query_header(tmp_path, caplog):
349349
@pytest.mark.parametrize(
350350
"query",
351351
[
352-
f"-- --height 5\nSELECT 1 AS count -- --width 6",
353-
f"-- --height 5\nSELECT 1 AS count\n-- --width 6",
354-
f"-- --height 5\nSELECT 1 AS count\n/* --width 6 */",
355-
f"-- --height 5\n-- --width 6\nSELECT 1 AS count",
356-
f"-- --height 5\n/* --width 6 */\nSELECT 1 AS count",
357-
f"/* --height 5*/\n/* --width 6 */\nSELECT 1 AS count",
358-
f"/* --height 5*/\n-- --width 6 */\nSELECT 1 AS count",
359-
]
352+
"-- --height 5\nSELECT 1 AS count -- --width 6",
353+
"-- --height 5\nSELECT 1 AS count\n-- --width 6",
354+
"-- --height 5\nSELECT 1 AS count\n/* --width 6 */",
355+
"-- --height 5\n-- --width 6\nSELECT 1 AS count",
356+
"-- --height 5\n/* --width 6 */\nSELECT 1 AS count",
357+
"/* --height 5*/\n/* --width 6 */\nSELECT 1 AS count",
358+
"/* --height 5*/\n-- --width 6 */\nSELECT 1 AS count",
359+
],
360360
)
361361
def test_dashboard_ignores_comment_on_other_lines(tmp_path, query):
362362
ws = create_autospec(WorkspaceClient)
@@ -377,7 +377,7 @@ def test_dashboard_ignores_comment_on_other_lines(tmp_path, query):
377377
[
378378
"SELECT 1\n-- --width 6 --height 6",
379379
"SELECT 1\n/*\n--width 6\n--height 6*/",
380-
]
380+
],
381381
)
382382
def test_dashboard_ignores_non_header_comment(tmp_path, query):
383383
ws = create_autospec(WorkspaceClient)

0 commit comments

Comments
 (0)