Skip to content

Commit 3af62cc

Browse files
committed
lint
Signed-off-by: Sajid Alam <[email protected]>
1 parent a84e4d5 commit 3af62cc

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ sign-off:
4646
test-no-spark: dataset-doctests-no-spark
4747
cd kedro-datasets && pytest tests --no-cov --ignore tests/spark --ignore tests/databricks --numprocesses 4 --dist loadfile
4848

49+
4950
# kedro-datasets/snowflake tests skipped from default scope
5051
test-snowflake-only:
5152
cd kedro-datasets && pytest --no-cov --numprocesses 1 --dist loadfile -m snowflake

kedro-datasets/kedro_datasets/_utils/databricks_utils.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"""Utility functions for Databricks."""
2+
from __future__ import annotations
3+
4+
import logging
15
import os
26
from fnmatch import fnmatch
37
from pathlib import PurePosixPath
@@ -10,8 +14,6 @@
1014
from databricks.connect import DatabricksSession
1115
from pyspark.dbutils import DBUtils
1216

13-
import logging
14-
1517
logger = logging.getLogger(__name__)
1618

1719

@@ -36,7 +38,7 @@ def strip_dbfs_prefix(path: str, prefix: str = "/dbfs") -> str:
3638
return path[len(prefix) :] if path.startswith(prefix) else path
3739

3840

39-
def dbfs_glob(pattern: str, dbutils: "DBUtils") -> list[str]:
41+
def dbfs_glob(pattern: str, dbutils: DBUtils) -> list[str]:
4042
"""Perform a custom glob search in DBFS using the provided pattern.
4143
It is assumed that version paths are managed by Kedro only.
4244
@@ -63,7 +65,7 @@ def dbfs_glob(pattern: str, dbutils: "DBUtils") -> list[str]:
6365
return sorted(matched)
6466

6567

66-
def get_dbutils(spark: Union[SparkSession, "DatabricksSession"]) -> "DBUtils":
68+
def get_dbutils(spark: SparkSession | DatabricksSession) -> DBUtils:
6769
"""Get the instance of 'dbutils' or None if the one could not be found."""
6870
dbutils = globals().get("dbutils")
6971
if dbutils:
@@ -87,7 +89,7 @@ def get_dbutils(spark: Union[SparkSession, "DatabricksSession"]) -> "DBUtils":
8789
return dbutils
8890

8991

90-
def dbfs_exists(pattern: str, dbutils: "DBUtils") -> bool:
92+
def dbfs_exists(pattern: str, dbutils: DBUtils) -> bool:
9193
"""Perform an `ls` list operation in DBFS using the provided pattern.
9294
It is assumed that version paths are managed by Kedro.
9395
Broad `Exception` is present due to `dbutils.fs.ExecutionError` that

kedro-datasets/kedro_datasets/_utils/spark_utils.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
"""Utility functions for Spark."""
2+
from __future__ import annotations
3+
14
import json
5+
import logging
26
import os
37
from copy import deepcopy
48
from pathlib import PurePosixPath
@@ -18,12 +22,10 @@
1822
from databricks.connect import DatabricksSession
1923
from pyspark.sql.types import StructType
2024

21-
import logging
22-
2325
logger = logging.getLogger(__name__)
2426

2527

26-
def get_spark() -> Union[SparkSession, "DatabricksSession"]:
28+
def get_spark() -> SparkSession | DatabricksSession:
2729
"""
2830
Returns the SparkSession. In case databricks-connect is available we use it for
2931
extended configuration mechanisms and notebook compatibility,
@@ -46,7 +48,7 @@ def get_spark() -> Union[SparkSession, "DatabricksSession"]:
4648
return spark
4749

4850

49-
def get_spark_with_remote_support() -> Union[SparkSession, "DatabricksSession"]:
51+
def get_spark_with_remote_support() -> SparkSession | DatabricksSession:
5052
"""Get Spark session with support for Spark Connect and Databricks Connect.
5153
5254
This function attempts to create a Spark session in the following order:
@@ -183,7 +185,7 @@ def get_spark_filesystem(
183185
raise ImportError(msg) from exc
184186

185187

186-
def load_spark_schema_from_file(schema_config: dict[str, Any]) -> "StructType":
188+
def load_spark_schema_from_file(schema_config: dict[str, Any]) -> StructType:
187189
"""Load Spark schema from JSON file.
188190
189191
Args:

kedro-datasets/tests/_utils/test_databricks_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_get_dbutils_no_ipython(self, mock_globals):
3232

3333
with patch.dict("sys.modules", {"pyspark.dbutils": None, "IPython": None}):
3434
result = get_dbutils(MagicMock())
35-
assert result is None or result is not None
35+
assert result is None
3636

3737

3838
class TestValidateDatabricksPath:

0 commit comments

Comments
 (0)