Skip to content

Commit 1178d40

Browse files
fix: Address pre-commit formatting and line length issues
- Fix line length violation in firebolt_dialect.py (90 > 88 characters) - Apply isort and black formatting fixes from pre-commit hooks - Ensure code passes flake8 line length requirements Co-Authored-By: [email protected] <[email protected]>
1 parent 5d851f2 commit 1178d40

File tree

2 files changed

+30
-21
lines changed

2 files changed

+30
-21
lines changed

src/firebolt_db/firebolt_dialect.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55

66
import firebolt.db as dbapi
77
import sqlalchemy.types as sqltypes
8-
from firebolt.client.auth import Auth, ClientCredentials, UsernamePassword, FireboltCore
8+
from firebolt.client.auth import (
9+
Auth,
10+
ClientCredentials,
11+
FireboltCore,
12+
UsernamePassword,
13+
)
914
from firebolt.db import Cursor
1015
from sqlalchemy.engine import Connection as AlchemyConnection
1116
from sqlalchemy.engine import ExecutionContext, default
@@ -148,29 +153,31 @@ def create_connect_args(self, url: URL) -> Tuple[List, Dict]:
148153
For Core: firebolt://db_name?url=http://localhost:8080 (full URL in url parameter)
149154
"""
150155
parameters = dict(url.query)
151-
156+
152157
is_core_connection = "url" in parameters
153-
core_url = parameters.pop("url", None) if is_core_connection else None
154-
158+
core_url = (
159+
parameters.pop("url", None) if is_core_connection else None
160+
)
161+
155162
# parameters are all passed as a string, we need to convert
156163
# bool flag to boolean for SDK compatibility
157164
token_cache_flag = bool(strtobool(parameters.pop("use_token_cache", "True")))
158-
165+
159166
if is_core_connection:
160167
auth = _determine_auth("", "", token_cache_flag, is_core=True)
161168
else:
162169
auth = _determine_auth(url.username, url.password, token_cache_flag)
163-
170+
164171
kwargs: Dict[str, Union[str, Auth, Dict[str, Any], None]] = {
165172
"database": url.host or None,
166173
"auth": auth,
167174
"engine_name": url.database,
168175
"additional_parameters": {},
169176
}
170-
177+
171178
if core_url:
172179
kwargs["url"] = core_url
173-
180+
174181
additional_parameters = {}
175182
if "account_name" in parameters:
176183
kwargs["account_name"] = parameters.pop("account_name")
@@ -380,7 +387,9 @@ def get_is_nullable(column_is_nullable: int) -> bool:
380387
return column_is_nullable == 1
381388

382389

383-
def _determine_auth(key: str, secret: str, token_cache_flag: bool = True, is_core: bool = False) -> Auth:
390+
def _determine_auth(
391+
key: str, secret: str, token_cache_flag: bool = True, is_core: bool = False
392+
) -> Auth:
384393
if is_core:
385394
return FireboltCore()
386395
elif "@" in key:

tests/unit/test_firebolt_dialect.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import sqlalchemy
55
import sqlalchemy.types as sqltypes
66
from conftest import MockCursor, MockDBApi
7+
from firebolt.client.auth import FireboltCore
78
from pytest import mark, raises
89
from sqlalchemy.engine import url
910
from sqlalchemy.exc import ArgumentError
@@ -18,7 +19,6 @@
1819
)
1920
from firebolt_db.firebolt_dialect import dialect as dialect_definition
2021
from firebolt_db.firebolt_dialect import resolve_type
21-
from firebolt.client.auth import FireboltCore
2222

2323

2424
class TestFireboltDialect:
@@ -305,37 +305,37 @@ def test_unicode_description(
305305

306306
def test_create_connect_args_core_connection(self, dialect: FireboltDialect):
307307
connection_url = (
308-
"test_engine://test_db_name/test_engine_name?"
309-
"url=http://localhost:8080"
308+
"test_engine://test_db_name/test_engine_name?" "url=http://localhost:8080"
310309
)
311310
u = url.make_url(connection_url)
312311
result_list, result_dict = dialect.create_connect_args(u)
313-
312+
314313
assert result_dict["engine_name"] == "test_engine_name"
315314
assert result_dict["database"] == "test_db_name"
316315
assert result_dict["url"] == "http://localhost:8080"
317316
assert isinstance(result_dict["auth"], FireboltCore)
318317
assert "account_name" not in result_dict
319318
assert result_list == []
320319

321-
def test_create_connect_args_core_connection_with_database(self, dialect: FireboltDialect):
322-
connection_url = (
323-
"test_engine://test_db_name?"
324-
"url=http://localhost:8080"
325-
)
320+
def test_create_connect_args_core_connection_with_database(
321+
self, dialect: FireboltDialect
322+
):
323+
connection_url = "test_engine://test_db_name?" "url=http://localhost:8080"
326324
u = url.make_url(connection_url)
327325
result_list, result_dict = dialect.create_connect_args(u)
328-
326+
329327
assert result_dict["database"] == "test_db_name"
330328
assert result_dict["url"] == "http://localhost:8080"
331329
assert isinstance(result_dict["auth"], FireboltCore)
332330
assert result_dict["engine_name"] is None
333331
assert result_list == []
334332

335-
def test_create_connect_args_core_no_credentials_required(self, dialect: FireboltDialect):
333+
def test_create_connect_args_core_no_credentials_required(
334+
self, dialect: FireboltDialect
335+
):
336336
connection_url = "test_engine://test_db_name?url=http://localhost:8080"
337337
u = url.make_url(connection_url)
338-
338+
339339
result_list, result_dict = dialect.create_connect_args(u)
340340
assert isinstance(result_dict["auth"], FireboltCore)
341341
assert "account_name" not in result_dict

0 commit comments

Comments
 (0)