Skip to content

Commit 1b4d438

Browse files
committed
Add linting to Makefile
This commits will extend the `Makefile` introduced in #54 to include a `lint` command and the `test-package.yml` GitHub actions template updated to make use of the `make` commands. Additionally, linting will be applied to the codebase.
1 parent 799dca4 commit 1b4d438

File tree

6 files changed

+15
-14
lines changed

6 files changed

+15
-14
lines changed

.github/workflows/test-package.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,10 @@ jobs:
3636
run: |
3737
poetry install --all-extras
3838
- name: Lint with flake8
39-
run: |
40-
# stop the build if there are Python syntax errors or undefined names
41-
poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
42-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
43-
poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=119 --statistics --ignore E203,E266,E501,W503
39+
run: make lint
4440
- name: Test with pytest
4541
env:
4642
SQL_MOCK_CLICKHOUSE_HOST: 127.0.0.1
4743
SQL_MOCK_CLICKHOUSE_PORT: 8123
4844
SQL_MOCK_CLICKHOUSE_USER: default
49-
run: |
50-
poetry run pytest tests/
45+
run: make test

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ SHELL := /bin/bash
55
help: ## Show all available commands
66
@awk 'BEGIN {FS = ":.*##"; printf "Usage: make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-13s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST);
77

8+
.PHONY: lint
9+
lint: ## Lint code with flake8
10+
poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # stop the build if there are Python syntax errors or undefined names
11+
poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=119 --statistics --ignore E203,E266,E501,W503 # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
12+
813
.PHONY: test
914
test: ## Run test pipeline
1015
poetry run pytest tests/

src/sql_mock/bigquery/column_mocks.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from typing import Any
2+
23
from sql_mock.column_mocks import BaseColumnMock
34

45

@@ -7,7 +8,7 @@ class BigQueryColumnMock(BaseColumnMock):
78

89

910
class Boolean(BigQueryColumnMock):
10-
dtype = 'Boolean'
11+
dtype = "Boolean"
1112

1213

1314
class Int(BigQueryColumnMock):
@@ -33,7 +34,7 @@ def __init__(self, default, precision, scale, nullable=False) -> None:
3334

3435

3536
class Timestamp(BigQueryColumnMock):
36-
dtype = 'Timestamp'
37+
dtype = "Timestamp"
3738

3839

3940
class Array(BigQueryColumnMock):
@@ -43,7 +44,7 @@ def __init__(
4344
self,
4445
inner_type: BigQueryColumnMock,
4546
default: Any,
46-
nullable: bool=False,
47+
nullable: bool = False,
4748
) -> None:
4849
self.dtype = f"Array<{inner_type.dtype}>"
4950
super().__init__(default, nullable)

src/sql_mock/clickhouse/column_mocks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from typing import Any
2+
23
from sql_mock.column_mocks import BaseColumnMock
34

45

@@ -50,7 +51,7 @@ def __init__(
5051
self,
5152
inner_type: ClickhouseColumnMock,
5253
default: Any,
53-
nullable: bool=False,
54+
nullable: bool = False,
5455
) -> None:
5556
self.dtype = f"Array({inner_type.dtype})"
5657
super().__init__(default, nullable)

tests/sql_mock/redshift/test_column_mocks.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from sql_mock.redshift.column_mocks import RedshiftColumnMock, DECIMAL
1+
from sql_mock.redshift.column_mocks import DECIMAL, RedshiftColumnMock
22

33

44
def test_init_nullable():
@@ -45,4 +45,3 @@ def test_decimal_initialization_nullable(self):
4545
assert decimal_col.dtype == "DECIMAL(10, 2)"
4646
assert decimal_col.default is None
4747
assert decimal_col.nullable
48-

tests/test_table_mocks/test_assert_equal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class MockTestTable(BaseTableMock):
4747
id="Matching data - Missing keys ignored - Order ignored - including mixed None and int values",
4848
),
4949
pytest.param(
50-
[{"name":None, "age": 25, "city": "New York"}, {"name": "Bob", "age": 30, "city": "Munich"}], # data
50+
[{"name": None, "age": 25, "city": "New York"}, {"name": "Bob", "age": 30, "city": "Munich"}], # data
5151
[{"name": None, "age": 25}, {"name": "Bob", "age": 30}], # expected_data
5252
True, # ignore_missing_keys
5353
True, # ignore_order

0 commit comments

Comments
 (0)