Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add linting to Makefile #55

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,10 @@ jobs:
run: |
poetry install --all-extras
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=119 --statistics --ignore E203,E266,E501,W503
run: make lint
- name: Test with pytest
env:
SQL_MOCK_CLICKHOUSE_HOST: 127.0.0.1
SQL_MOCK_CLICKHOUSE_PORT: 8123
SQL_MOCK_CLICKHOUSE_USER: default
run: |
poetry run pytest tests/
run: make test
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ SHELL := /bin/bash
help: ## Show all available commands
@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);

.PHONY: lint
lint: ## Lint code with flake8
poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # stop the build if there are Python syntax errors or undefined names
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

.PHONY: test
test: ## Run test pipeline
poetry run pytest tests/
Expand Down
7 changes: 4 additions & 3 deletions src/sql_mock/bigquery/column_mocks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any

from sql_mock.column_mocks import BaseColumnMock


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


class Boolean(BigQueryColumnMock):
dtype = 'Boolean'
dtype = "Boolean"


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


class Timestamp(BigQueryColumnMock):
dtype = 'Timestamp'
dtype = "Timestamp"


class Array(BigQueryColumnMock):
Expand All @@ -43,7 +44,7 @@ def __init__(
self,
inner_type: BigQueryColumnMock,
default: Any,
nullable: bool=False,
nullable: bool = False,
) -> None:
self.dtype = f"Array<{inner_type.dtype}>"
super().__init__(default, nullable)
3 changes: 2 additions & 1 deletion src/sql_mock/clickhouse/column_mocks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any

from sql_mock.column_mocks import BaseColumnMock


Expand Down Expand Up @@ -50,7 +51,7 @@ def __init__(
self,
inner_type: ClickhouseColumnMock,
default: Any,
nullable: bool=False,
nullable: bool = False,
) -> None:
self.dtype = f"Array({inner_type.dtype})"
super().__init__(default, nullable)
3 changes: 1 addition & 2 deletions tests/sql_mock/redshift/test_column_mocks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from sql_mock.redshift.column_mocks import RedshiftColumnMock, DECIMAL
from sql_mock.redshift.column_mocks import DECIMAL, RedshiftColumnMock


def test_init_nullable():
Expand Down Expand Up @@ -45,4 +45,3 @@ def test_decimal_initialization_nullable(self):
assert decimal_col.dtype == "DECIMAL(10, 2)"
assert decimal_col.default is None
assert decimal_col.nullable

2 changes: 1 addition & 1 deletion tests/test_table_mocks/test_assert_equal.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class MockTestTable(BaseTableMock):
id="Matching data - Missing keys ignored - Order ignored - including mixed None and int values",
),
pytest.param(
[{"name":None, "age": 25, "city": "New York"}, {"name": "Bob", "age": 30, "city": "Munich"}], # data
[{"name": None, "age": 25, "city": "New York"}, {"name": "Bob", "age": 30, "city": "Munich"}], # data
[{"name": None, "age": 25}, {"name": "Bob", "age": 30}], # expected_data
True, # ignore_missing_keys
True, # ignore_order
Expand Down
Loading