Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

Commit ae0a181

Browse files
authored
Fix/consolidated security and error handling (#38)
* feat: improve error handling and validation * build: update pre-commit configuration from example * ci: update pre-commit workflow and apply automatic fixes
1 parent 3af06d2 commit ae0a181

6 files changed

Lines changed: 94 additions & 89 deletions

File tree

.github/workflows/pre-commit.yml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
1-
name: pre-commits CI
1+
name: pre-commit
22

33
on:
4-
push:
5-
paths:
6-
- dataform2looker/**
7-
- tests/**
8-
- .pre-commit-config.yaml
94
pull_request:
10-
branches: [ "main" ]
5+
push:
6+
branches: [main]
117

128
jobs:
13-
test:
9+
pre-commit:
1410
runs-on: ubuntu-latest
1511
steps:
1612
- uses: actions/checkout@v4
17-
- name: Set up Python "3.10"
18-
uses: actions/setup-python@v4
13+
- uses: actions/setup-python@v5
1914
with:
2015
python-version: "3.10"
21-
- name: Install pre-commit
22-
run: pip install pre-commit
23-
- name: Run pre-commit hooks
24-
run: pre-commit run --all-files
16+
- name: Install poetry
17+
run: pipx install poetry
18+
- uses: pre-commit/action@v3.0.1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,4 @@ result.json
171171
.vscode/
172172

173173
.DS_Store
174+
.envrc

.pre-commit-config.yaml

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,45 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.6.0
3+
rev: v6.0.0
44
hooks:
5-
- id: check-added-large-files
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-toml
8+
- id: check-merge-conflict
9+
- id: check-ast
610
- id: check-case-conflict
11+
- id: check-docstring-first
712
- id: check-json
8-
- id: check-symlinks
913
- id: check-yaml
10-
- id: destroyed-symlinks
14+
- id: debug-statements
1115
- id: detect-private-key
12-
- id: end-of-file-fixer
13-
- id: fix-byte-order-marker
14-
- id: trailing-whitespace
1516
- id: mixed-line-ending
16-
args: [--fix=auto]
1717
- id: pretty-format-json
18-
args: [--autofix, --no-sort-keys]
18+
args: [--autofix, --indent, "4"]
19+
- repo: https://github.com/Lucas-C/pre-commit-hooks
20+
rev: v1.5.5
21+
hooks:
22+
- id: remove-crlf
23+
- id: forbid-crlf
24+
- repo: https://github.com/adrienverge/yamllint
25+
rev: v1.37.1
26+
hooks:
27+
- id: yamllint
28+
args: ["-d {extends: relaxed, rules: {line-length: disable}}", "-s"]
1929
- repo: https://github.com/astral-sh/ruff-pre-commit
20-
rev: v0.6.4
30+
rev: v0.14.6
2131
hooks:
2232
- id: ruff
2333
args: [ --fix ]
2434
- id: ruff-format
2535
- repo: https://github.com/crate-ci/typos
26-
rev: v1.24.5
36+
rev: v1.39.2
2737
hooks:
2838
- id: typos
29-
- repo: https://github.com/python-poetry/poetry
30-
rev: '1.8.3'
31-
hooks:
32-
- id: poetry-check
33-
- id: poetry-lock
34-
- id: poetry-export
35-
- id: poetry-install
39+
- repo: https://github.com/python-poetry/poetry
40+
rev: '1.8.3'
41+
hooks:
42+
- id: poetry-check
43+
- id: poetry-lock
44+
- id: poetry-export
45+
- id: poetry-install

dataform2looker/lookml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def __init__(
4545
def save_lookml_views(self) -> None:
4646
"""Generates and saves LookML view files for each table.""" # noqa: E501
4747
for table_name, table_template in self.lookml_templates.items():
48-
file_path = f"{self.target_folder_path}/" f"{table_name}.view.lkml"
48+
file_path = f"{self.target_folder_path}/{table_name}.view.lkml"
4949
logging.debug(f"Creating file {file_path}")
5050
with open(file_path, "w") as f:
5151
f.write(table_template)

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Test configuraitons."""
1+
"""Test configurations."""
22

33
from pytest import FixtureRequest, Parser, fixture
44

tests/dataform_result.json

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,58 @@
11
{
2-
"tables": [
3-
{
4-
"type": "table",
5-
"target": {
6-
"schema": "chicago_taxi_trips",
7-
"name": "taxi_trips",
8-
"database": "bigquery-public-data"
9-
},
10-
"query": "\n\n SELECT 1 \n",
11-
"disabled": false,
12-
"fileName": "",
13-
"tags": [
14-
"tag1"
15-
],
16-
"dependencyTargets": [],
17-
"canonicalTarget": {
18-
"schema": "chicago_taxi_trips",
19-
"name": "taxi_trips",
20-
"database": "bigquery-public-data"
21-
},
22-
"enumType": "TABLE"
2+
"assertions": [],
3+
"dataformCoreVersion": "3.0.0",
4+
"declarations": [],
5+
"graphErrors": {},
6+
"projectConfig": {
7+
"assertionSchema": "chicago_taxi_trips",
8+
"defaultDatabase": "bigquery-public-data",
9+
"defaultLocation": "EU",
10+
"defaultSchema": "chicago_taxi_trips",
11+
"warehouse": "bigquery"
2312
},
24-
{
25-
"type": "table",
26-
"target": {
27-
"schema": "chicago_crime",
28-
"name": "crime",
29-
"database": "bigquery-public-data"
30-
},
31-
"query": "\n\n SELECT 1 \n",
32-
"disabled": false,
33-
"fileName": "",
34-
"tags": [
35-
"tag2"
36-
],
37-
"dependencyTargets": [],
38-
"canonicalTarget": {
39-
"schema": "chicago_crime",
40-
"name": "crime",
41-
"database": "bigquery-public-data"
42-
},
43-
"enumType": "TABLE"
44-
}
45-
],
46-
"assertions": [],
47-
"projectConfig": {
48-
"warehouse": "bigquery",
49-
"defaultSchema": "chicago_taxi_trips",
50-
"assertionSchema": "chicago_taxi_trips",
51-
"defaultDatabase": "bigquery-public-data",
52-
"defaultLocation": "EU"
53-
},
54-
"graphErrors": {},
55-
"declarations": [],
56-
"dataformCoreVersion": "3.0.0",
57-
"targets": []
13+
"tables": [
14+
{
15+
"canonicalTarget": {
16+
"database": "bigquery-public-data",
17+
"name": "taxi_trips",
18+
"schema": "chicago_taxi_trips"
19+
},
20+
"dependencyTargets": [],
21+
"disabled": false,
22+
"enumType": "TABLE",
23+
"fileName": "",
24+
"query": "\n\n SELECT 1 \n",
25+
"tags": [
26+
"tag1"
27+
],
28+
"target": {
29+
"database": "bigquery-public-data",
30+
"name": "taxi_trips",
31+
"schema": "chicago_taxi_trips"
32+
},
33+
"type": "table"
34+
},
35+
{
36+
"canonicalTarget": {
37+
"database": "bigquery-public-data",
38+
"name": "crime",
39+
"schema": "chicago_crime"
40+
},
41+
"dependencyTargets": [],
42+
"disabled": false,
43+
"enumType": "TABLE",
44+
"fileName": "",
45+
"query": "\n\n SELECT 1 \n",
46+
"tags": [
47+
"tag2"
48+
],
49+
"target": {
50+
"database": "bigquery-public-data",
51+
"name": "crime",
52+
"schema": "chicago_crime"
53+
},
54+
"type": "table"
55+
}
56+
],
57+
"targets": []
5858
}

0 commit comments

Comments
 (0)