Skip to content

Commit 5e20eea

Browse files
authored
More cleanup work for forward compatibility (#865)
1 parent fe9fa10 commit 5e20eea

File tree

15 files changed

+23
-25
lines changed

15 files changed

+23
-25
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
- Removed pins for pandas and pydantic to ease user burdens ([874](https://github.com/databricks/dbt-databricks/pull/874))
1010
- Add more relation types to make codegen happy ([875](https://github.com/databricks/dbt-databricks/pull/875))
11+
- add UP ruleset ([865](https://github.com/databricks/dbt-databricks/pull/865))
1112

1213
## dbt-databricks 1.9.0 (December 9, 2024)
1314

dbt/adapters/databricks/api_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def _poll_api(
246246

247247

248248
@dataclass(frozen=True, eq=True, unsafe_hash=True)
249-
class CommandExecution(object):
249+
class CommandExecution:
250250
command_id: str
251251
context_id: str
252252
cluster_id: str

dbt/adapters/databricks/column.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def data_type(self) -> str:
2828
return self.translate_type(self.dtype)
2929

3030
def __repr__(self) -> str:
31-
return "<DatabricksColumn {} ({})>".format(self.name, self.data_type)
31+
return f"<DatabricksColumn {self.name} ({self.data_type})>"
3232

3333
@staticmethod
3434
def get_name(column: dict[str, Any]) -> str:

dbt/adapters/databricks/connections.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
import time
66
import uuid
77
import warnings
8-
from collections.abc import Callable, Iterator, Sequence
8+
from collections.abc import Callable, Hashable, Iterator, Sequence
99
from contextlib import contextmanager
1010
from dataclasses import dataclass
1111
from multiprocessing.context import SpawnContext
1212
from numbers import Number
1313
from threading import get_ident
14-
from typing import TYPE_CHECKING, Any, Hashable, Optional, cast
14+
from typing import TYPE_CHECKING, Any, Optional, cast
1515

1616
from dbt_common.events.contextvars import get_node_info
1717
from dbt_common.events.functions import fire_event
@@ -488,7 +488,7 @@ def add_query(
488488
try:
489489
log_sql = redact_credentials(sql)
490490
if abridge_sql_log:
491-
log_sql = "{}...".format(log_sql[:512])
491+
log_sql = f"{log_sql[:512]}..."
492492

493493
fire_event(
494494
SQLQuery(

dbt/adapters/databricks/credentials.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,16 @@ def __post_init__(self) -> None:
136136
def validate_creds(self) -> None:
137137
for key in ["host", "http_path"]:
138138
if not getattr(self, key):
139-
raise DbtConfigError(
140-
"The config '{}' is required to connect to Databricks".format(key)
141-
)
139+
raise DbtConfigError(f"The config '{key}' is required to connect to Databricks")
142140
if not self.token and self.auth_type != "oauth":
143141
raise DbtConfigError(
144-
("The config `auth_type: oauth` is required when not using access token")
142+
"The config `auth_type: oauth` is required when not using access token"
145143
)
146144

147145
if not self.client_id and self.client_secret:
148146
raise DbtConfigError(
149-
(
150-
"The config 'client_id' is required to connect "
151-
"to Databricks when 'client_secret' is present"
152-
)
147+
"The config 'client_id' is required to connect "
148+
"to Databricks when 'client_secret' is present"
153149
)
154150

155151
@classmethod

dbt/adapters/databricks/impl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ def _get_catalog_for_relation_map(
539539
used_schemas: frozenset[tuple[str, str]],
540540
) -> tuple["Table", list[Exception]]:
541541
with executor(self.config) as tpe:
542-
futures: list[Future["Table"]] = []
542+
futures: list[Future[Table]] = []
543543
for schema, relations in relation_map.items():
544544
if schema in used_schemas:
545545
identifier = get_identifier_list_string(relations)
@@ -804,7 +804,7 @@ def get_from_relation(
804804
) -> DatabricksRelationConfig:
805805
"""Get the relation config from the relation."""
806806

807-
relation_config = super(DeltaLiveTableAPIBase, cls).get_from_relation(adapter, relation)
807+
relation_config = super().get_from_relation(adapter, relation)
808808

809809
# Ensure any current refreshes are completed before returning the relation config
810810
tblproperties = cast(TblPropertiesConfig, relation_config.config["tblproperties"])

dbt/adapters/databricks/python_models/run_tracking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from dbt.adapters.databricks.logging import logger
77

88

9-
class PythonRunTracker(object):
9+
class PythonRunTracker:
1010
_run_ids: set[str] = set()
1111
_commands: set[CommandExecution] = set()
1212
_lock = threading.Lock()

dbt/adapters/databricks/relation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from collections.abc import Iterable
22
from dataclasses import dataclass, field
3-
from typing import Any, Optional, Type
3+
from typing import Any, Optional, Type # noqa
44

55
from dbt_common.dataclass_schema import StrEnum
66
from dbt_common.exceptions import DbtRuntimeError
@@ -133,7 +133,7 @@ def matches(
133133
return match
134134

135135
@classproperty
136-
def get_relation_type(cls) -> Type[DatabricksRelationType]:
136+
def get_relation_type(cls) -> Type[DatabricksRelationType]: # noqa
137137
return DatabricksRelationType
138138

139139
def information_schema(self, view_name: Optional[str] = None) -> InformationSchema:

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ dependencies = [
7878
"ruff",
7979
"types-requests",
8080
"debugpy",
81+
"pydantic>=1.10.0, <2",
8182
]
8283
path = ".hatch"
8384
python = "3.9"
@@ -101,7 +102,7 @@ line-length = 100
101102
target-version = 'py39'
102103

103104
[tool.ruff.lint]
104-
select = ["E", "W", "F", "I"]
105+
select = ["E", "W", "F", "I", "UP"]
105106
ignore = ["E203"]
106107

107108
[tool.pytest.ini_options]

tests/functional/adapter/ephemeral/test_ephemeral.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def test_ephemeral_nested(self, project):
3333
results = util.run_dbt(["run"])
3434
assert len(results) == 2
3535
assert os.path.exists("./target/run/test/models/root_view.sql")
36-
with open("./target/run/test/models/root_view.sql", "r") as fp:
36+
with open("./target/run/test/models/root_view.sql") as fp:
3737
sql_file = fp.read()
3838

3939
sql_file = re.sub(r"\d+", "", sql_file)

0 commit comments

Comments
 (0)