Skip to content

Commit 9bd8aea

Browse files
committed
address a comment
1 parent ab95e64 commit 9bd8aea

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

python/pyspark/sql/streaming/listener.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,17 @@ class StreamingQueryListener(ABC):
6464
"""
6565

6666
def _set_spark_session(
67-
self, spark: "SparkSession" # type: ignore[name-defined] # noqa: F821
67+
self, session: "SparkSession" # type: ignore[name-defined] # noqa: F821
6868
) -> None:
69-
self._sparkSession = spark
69+
if self.spark is not None:
70+
self.spark = session
7071

7172
@property
7273
def spark(self) -> Optional["SparkSession"]: # type: ignore[name-defined] # noqa: F821
73-
if hasattr(self, "_sparkSession"):
74-
return self._sparkSession
75-
else:
76-
return None
74+
return getattr(self, "_sparkSession", None)
7775

7876
@spark.setter
79-
def spark(self, session):
77+
def spark(self, session) -> None:
8078
# For backward compatibility
8179
self._sparkSession = session
8280

0 commit comments

Comments
 (0)