Skip to content

Commit d759050

Browse files
add from __future__ import annotations to remove string literals around forward refs, remove some unused imports
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent 13ffb8d commit d759050

File tree

4 files changed

+26
-32
lines changed

4 files changed

+26
-32
lines changed

src/databricks/sql/backend/databricks_client.py

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,17 @@
88
- Fetching metadata about catalogs, schemas, tables, and columns
99
"""
1010

11+
from __future__ import annotations
12+
1113
from abc import ABC, abstractmethod
12-
from typing import Dict, Tuple, List, Optional, Any, Union, TYPE_CHECKING
14+
from typing import Dict, List, Optional, Any, Union, TYPE_CHECKING
1315

1416
if TYPE_CHECKING:
1517
from databricks.sql.client import Cursor
18+
from databricks.sql.result_set import ResultSet
1619

1720
from databricks.sql.thrift_api.TCLIService import ttypes
1821
from databricks.sql.backend.types import SessionId, CommandId, CommandState
19-
from databricks.sql.utils import ExecuteResponse
20-
from databricks.sql.types import SSLOptions
21-
22-
# Forward reference for type hints
23-
from typing import TYPE_CHECKING
24-
25-
if TYPE_CHECKING:
26-
from databricks.sql.result_set import ResultSet
2722

2823

2924
class DatabricksClient(ABC):
@@ -82,12 +77,12 @@ def execute_command(
8277
max_rows: int,
8378
max_bytes: int,
8479
lz4_compression: bool,
85-
cursor: "Cursor",
80+
cursor: Cursor,
8681
use_cloud_fetch: bool,
8782
parameters: List[ttypes.TSparkParameter],
8883
async_op: bool,
8984
enforce_embedded_schema_correctness: bool,
90-
) -> Union["ResultSet", None]:
85+
) -> Union[ResultSet, None]:
9186
"""
9287
Executes a SQL command or query within the specified session.
9388
@@ -177,8 +172,8 @@ def get_query_state(self, command_id: CommandId) -> CommandState:
177172
def get_execution_result(
178173
self,
179174
command_id: CommandId,
180-
cursor: "Cursor",
181-
) -> "ResultSet":
175+
cursor: Cursor,
176+
) -> ResultSet:
182177
"""
183178
Retrieves the results of a previously executed command.
184179
@@ -205,8 +200,8 @@ def get_catalogs(
205200
session_id: SessionId,
206201
max_rows: int,
207202
max_bytes: int,
208-
cursor: "Cursor",
209-
) -> "ResultSet":
203+
cursor: Cursor,
204+
) -> ResultSet:
210205
"""
211206
Retrieves a list of available catalogs.
212207
@@ -234,10 +229,10 @@ def get_schemas(
234229
session_id: SessionId,
235230
max_rows: int,
236231
max_bytes: int,
237-
cursor: "Cursor",
232+
cursor: Cursor,
238233
catalog_name: Optional[str] = None,
239234
schema_name: Optional[str] = None,
240-
) -> "ResultSet":
235+
) -> ResultSet:
241236
"""
242237
Retrieves a list of schemas, optionally filtered by catalog and schema name patterns.
243238
@@ -267,12 +262,12 @@ def get_tables(
267262
session_id: SessionId,
268263
max_rows: int,
269264
max_bytes: int,
270-
cursor: "Cursor",
265+
cursor: Cursor,
271266
catalog_name: Optional[str] = None,
272267
schema_name: Optional[str] = None,
273268
table_name: Optional[str] = None,
274269
table_types: Optional[List[str]] = None,
275-
) -> "ResultSet":
270+
) -> ResultSet:
276271
"""
277272
Retrieves a list of tables, optionally filtered by catalog, schema, table name, and table types.
278273
@@ -304,12 +299,12 @@ def get_columns(
304299
session_id: SessionId,
305300
max_rows: int,
306301
max_bytes: int,
307-
cursor: "Cursor",
302+
cursor: Cursor,
308303
catalog_name: Optional[str] = None,
309304
schema_name: Optional[str] = None,
310305
table_name: Optional[str] = None,
311306
column_name: Optional[str] = None,
312-
) -> "ResultSet":
307+
) -> ResultSet:
313308
"""
314309
Retrieves a list of columns, optionally filtered by catalog, schema, table, and column name patterns.
315310

src/databricks/sql/backend/thrift_backend.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from decimal import Decimal
21
import errno
32
import logging
43
import math

src/databricks/sql/result_set.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
from __future__ import annotations
2+
13
from abc import ABC, abstractmethod
2-
from typing import List, Optional, Any, Union, TYPE_CHECKING
4+
from typing import List, Optional, TYPE_CHECKING
35

46
import logging
5-
import time
67
import pandas
78

9+
from databricks.sql.backend.databricks_client import DatabricksClient
810
from databricks.sql.backend.types import CommandId, CommandState
911

1012
try:
@@ -13,13 +15,11 @@
1315
pyarrow = None
1416

1517
if TYPE_CHECKING:
16-
from databricks.sql.backend.databricks_client import DatabricksClient
1718
from databricks.sql.backend.thrift_backend import ThriftDatabricksClient
1819
from databricks.sql.client import Connection
1920

20-
from databricks.sql.thrift_api.TCLIService import ttypes
2121
from databricks.sql.types import Row
22-
from databricks.sql.exc import Error, RequestError, CursorAlreadyClosedError
22+
from databricks.sql.exc import RequestError, CursorAlreadyClosedError
2323
from databricks.sql.utils import ExecuteResponse, ColumnTable, ColumnQueue
2424

2525
logger = logging.getLogger(__name__)
@@ -34,8 +34,8 @@ class ResultSet(ABC):
3434

3535
def __init__(
3636
self,
37-
connection: "Connection",
38-
backend: "DatabricksClient",
37+
connection: Connection,
38+
backend: DatabricksClient,
3939
command_id: CommandId,
4040
op_state: Optional[CommandState],
4141
has_been_closed_server_side: bool,
@@ -139,9 +139,9 @@ class ThriftResultSet(ResultSet):
139139

140140
def __init__(
141141
self,
142-
connection: "Connection",
142+
connection: Connection,
143143
execute_response: ExecuteResponse,
144-
thrift_client: "ThriftDatabricksClient",
144+
thrift_client: ThriftDatabricksClient,
145145
buffer_size_bytes: int = 104857600,
146146
arraysize: int = 10000,
147147
use_cloud_fetch: bool = True,

src/databricks/sql/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from databricks.sql import USER_AGENT_NAME
1010
from databricks.sql.backend.thrift_backend import ThriftDatabricksClient
1111
from databricks.sql.backend.databricks_client import DatabricksClient
12-
from databricks.sql.backend.types import SessionId, BackendType
12+
from databricks.sql.backend.types import SessionId
1313

1414
logger = logging.getLogger(__name__)
1515

0 commit comments

Comments
 (0)