Skip to content

Commit d9333ae

Browse files
authored
chore: add .editorconfig and update Pylance (#67)
* Add .editorconfig * Add __init__ to fix Pylance errors and isort
1 parent 46c511d commit d9333ae

18 files changed

+86
-56
lines changed

.editorconfig

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_style = space
7+
insert_final_newline = true
8+
trim_trailing_whitespace = true
9+
10+
# 4 space indentation
11+
[*.py]
12+
indent_size = 4
13+
14+
# 2 space indentation
15+
[*.{sql,json}]
16+
indent_size = 2
17+
18+
[*.{yml,yaml}]
19+
quote_type = single
20+
21+
[*.md]
22+
trim_trailing_whitespace = false
23+
indent_size = 2
24+
25+
[Makefile]
26+
indent_style = tab

.github/workflows/ci.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ jobs:
1010
name: 'Pre-commit checks'
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v3
14-
- uses: actions/setup-python@v3
15-
with:
16-
python-version: '3.x'
17-
- uses: pre-commit/[email protected]
13+
- uses: actions/checkout@v3
14+
- uses: actions/setup-python@v3
15+
with:
16+
python-version: '3.x'
17+
- uses: pre-commit/[email protected]
1818

1919
unit_test:
2020
name: 'Unit tests with coverage'

.github/workflows/python-publish.yml

+16-17
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,22 @@ permissions:
1010

1111
jobs:
1212
deploy:
13-
1413
runs-on: ubuntu-latest
1514

1615
steps:
17-
- uses: actions/checkout@v3
18-
- name: Set up Python
19-
uses: actions/setup-python@v3
20-
with:
21-
python-version: '3.x'
22-
- name: Install dependencies
23-
run: |
24-
python -m pip install --upgrade pip
25-
pip install build
26-
- name: Build package
27-
run: python -m build
28-
- name: Publish package
29-
uses: pypa/gh-action-pypi-publish@release/v1
30-
with:
31-
user: __token__
32-
password: ${{ secrets.PYPI_API_TOKEN }}
16+
- uses: actions/checkout@v3
17+
- name: Set up Python
18+
uses: actions/setup-python@v3
19+
with:
20+
python-version: '3.x'
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install build
25+
- name: Build package
26+
run: python -m build
27+
- name: Publish package
28+
uses: pypa/gh-action-pypi-publish@release/v1
29+
with:
30+
user: __token__
31+
password: ${{ secrets.PYPI_API_TOKEN }}

.pre-commit-config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ repos:
2323
# General quality checks
2424
- id: mixed-line-ending
2525
- id: trailing-whitespace
26-
args: [ --markdown-linebreak-ext=md ]
26+
args: [--markdown-linebreak-ext=md]
2727
- id: end-of-file-fixer
2828

2929
- repo: https://github.com/PyCQA/autoflake
@@ -56,6 +56,6 @@ repos:
5656
hooks:
5757
- id: flake8
5858
additional_dependencies:
59-
- "Flake8-pyproject~=1.1"
59+
- 'Flake8-pyproject~=1.1'
6060
args:
6161
- '.'

dbt/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from pkgutil import extend_path
2+
3+
__path__ = extend_path(__path__, __name__)

dbt/adapters/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from pkgutil import extend_path
2+
3+
__path__ = extend_path(__path__, __name__)

dbt/adapters/athena/__init__.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
from dbt.adapters.base import AdapterPlugin
2-
31
import dbt
42
from dbt.adapters.athena.connections import AthenaConnectionManager, AthenaCredentials
53
from dbt.adapters.athena.impl import AthenaAdapter
64
from dbt.adapters.athena.query_headers import _QueryComment
5+
from dbt.adapters.base import AdapterPlugin
76
from dbt.include import athena
87

98
Plugin = AdapterPlugin(adapter=AthenaAdapter, credentials=AthenaCredentials, include_path=athena.PACKAGE_PATH)

dbt/adapters/athena/connections.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
from typing import Any, ContextManager, Dict, List, Optional, Tuple
77

88
import tenacity
9-
from dbt.adapters.base import Credentials
10-
from dbt.adapters.sql import SQLConnectionManager
11-
from dbt.contracts.connection import AdapterResponse, Connection, ConnectionState
12-
from dbt.events import AdapterLogger
13-
from dbt.exceptions import FailedToConnectException, RuntimeException
149
from pyathena.connection import Connection as AthenaConnection
1510
from pyathena.cursor import Cursor
1611
from pyathena.error import OperationalError, ProgrammingError
@@ -31,6 +26,11 @@
3126

3227
from dbt.adapters.athena.config import get_boto3_config
3328
from dbt.adapters.athena.session import get_boto3_session
29+
from dbt.adapters.base import Credentials
30+
from dbt.adapters.sql import SQLConnectionManager
31+
from dbt.contracts.connection import AdapterResponse, Connection, ConnectionState
32+
from dbt.events import AdapterLogger
33+
from dbt.exceptions import FailedToConnectException, RuntimeException
3434

3535
logger = AdapterLogger("Athena")
3636

dbt/adapters/athena/impl.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
import agate
99
from botocore.exceptions import ClientError
10+
11+
from dbt.adapters.athena import AthenaConnectionManager
12+
from dbt.adapters.athena.config import get_boto3_config
13+
from dbt.adapters.athena.relation import AthenaRelation, AthenaSchemaSearchMap
1014
from dbt.adapters.base import available
1115
from dbt.adapters.base.impl import GET_CATALOG_MACRO_NAME
1216
from dbt.adapters.base.relation import BaseRelation, InformationSchema
@@ -16,10 +20,6 @@
1620
from dbt.events import AdapterLogger
1721
from dbt.exceptions import RuntimeException
1822

19-
from dbt.adapters.athena import AthenaConnectionManager
20-
from dbt.adapters.athena.config import get_boto3_config
21-
from dbt.adapters.athena.relation import AthenaRelation, AthenaSchemaSearchMap
22-
2323
logger = AdapterLogger("Athena")
2424

2525
boto3_client_lock = Lock()

dbt/adapters/athena/session.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import boto3.session
2+
23
from dbt.contracts.connection import Connection
34

45

dbt/include/athena/dbt_project.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
21
name: dbt_athena
32
version: 1.0
43
config-version: 2
54

6-
macro-paths: ["macros"]
5+
macro-paths: ['macros']
+4-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
default:
22
outputs:
3-
43
dev:
54
type: athena
65
s3_staging_dir: [s3_staging_dir]
@@ -10,9 +9,9 @@ default:
109

1110
prod:
1211
type: athena
13-
s3_staging_dir: [ s3_staging_dir ]
14-
region_name: [ region_name ]
15-
database: [ database name ]
16-
schema: [ prod_schema ]
12+
s3_staging_dir: [s3_staging_dir]
13+
region_name: [region_name]
14+
database: [database name]
15+
schema: [prod_schema]
1716

1817
target: dev

tests/functional/adapter/utils/test_utils.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
import pytest
2+
from tests.functional.adapter.fixture_datediff import (
3+
models__test_datediff_sql,
4+
seeds__data_datediff_csv,
5+
)
6+
27
from dbt.tests.adapter.utils.fixture_datediff import models__test_datediff_yml
38
from dbt.tests.adapter.utils.test_any_value import BaseAnyValue
49
from dbt.tests.adapter.utils.test_array_append import BaseArrayAppend
@@ -21,10 +26,6 @@
2126
from dbt.tests.adapter.utils.test_right import BaseRight
2227
from dbt.tests.adapter.utils.test_split_part import BaseSplitPart
2328
from dbt.tests.adapter.utils.test_string_literal import BaseStringLiteral
24-
from tests.functional.adapter.fixture_datediff import (
25-
models__test_datediff_sql,
26-
seeds__data_datediff_csv,
27-
)
2829

2930
models__array_concat_expected_sql = """
3031
select 1 as id, {{ array_construct([1,2,3,4,5,6]) }} as array_col

tests/unit/test_adapter.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77
import agate
88
import boto3
99
import pytest
10+
from moto import mock_athena, mock_glue, mock_s3
11+
12+
from dbt.adapters.athena import AthenaAdapter
13+
from dbt.adapters.athena import Plugin as AthenaPlugin
14+
from dbt.adapters.athena.connections import AthenaCursor, AthenaParameterFormatter
15+
from dbt.adapters.athena.relation import AthenaRelation
1016
from dbt.clients import agate_helper
1117
from dbt.contracts.connection import ConnectionState
1218
from dbt.contracts.files import FileHash
1319
from dbt.contracts.graph.compiled import CompiledModelNode
1420
from dbt.contracts.graph.parsed import DependsOn, NodeConfig
1521
from dbt.exceptions import FailedToConnectException, ValidationException
1622
from dbt.node_types import NodeType
17-
from moto import mock_athena, mock_glue, mock_s3
18-
19-
from dbt.adapters.athena import AthenaAdapter
20-
from dbt.adapters.athena import Plugin as AthenaPlugin
21-
from dbt.adapters.athena.connections import AthenaCursor, AthenaParameterFormatter
22-
from dbt.adapters.athena.relation import AthenaRelation
2323

2424
from .constants import AWS_REGION, BUCKET, DATA_CATALOG_NAME, DATABASE_NAME
2525
from .utils import (

tests/unit/test_connection_manager.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from unittest import mock
22

33
import pytest
4-
from dbt.contracts.connection import AdapterResponse
54
from pyathena.model import AthenaQueryExecution
65

76
from dbt.adapters.athena import AthenaConnectionManager
7+
from dbt.contracts.connection import AdapterResponse
88

99

1010
class TestAthenaConnectionManager:

tests/unit/test_query_headers.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from unittest import mock
22

3-
from dbt.adapters.base.query_headers import MacroQueryStringSetter
4-
53
from dbt.adapters.athena import _QueryComment
4+
from dbt.adapters.base.query_headers import MacroQueryStringSetter
65

76
from .constants import AWS_REGION, DATA_CATALOG_NAME, DATABASE_NAME
87
from .utils import config_from_parts_or_dicts

tests/unit/test_session.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import botocore.session
22
import pytest
3-
from dbt.contracts.connection import Connection
43

54
from dbt.adapters.athena import AthenaCredentials
65
from dbt.adapters.athena.session import get_boto3_session
6+
from dbt.contracts.connection import Connection
77

88

99
class TestSession:

tests/unit/utils.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import agate
55
import boto3
6+
67
from dbt.config.project import PartialProject
78

89
from .constants import AWS_REGION, BUCKET, CATALOG_ID, DATA_CATALOG_NAME, DATABASE_NAME

0 commit comments

Comments
 (0)