Skip to content

Conversation

@gaogaotiantian
Copy link
Contributor

@gaogaotiantian gaogaotiantian commented Jan 8, 2026

What changes were proposed in this pull request?

  • Add overload stubs for remote_only.
  • Distinguish remote and normal SparkSession
  • Do some type assertions so we don't need all the ignore comments

Why are the changes needed?

When we do something like

@property
@remote_only
def method(self):
    ...

The latest version of mypy is not happy because it believes remote_only can return a property. We can't do @property on a property.

By adding the explicit overload, mypy knows that remote_only always return a callable when given a callable.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Wait for CI.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Cursor (claude-4.5-opus-high)

@github-actions
Copy link

github-actions bot commented Jan 8, 2026

JIRA Issue Information

=== Sub-task SPARK-54954 ===
Summary: Fix remote related type hints in pyspark/util.py
Assignee: None
Status: Open
Affected: ["4.2.0"]


This comment was automatically generated by GitHub Actions

@gaogaotiantian gaogaotiantian changed the title [SPARK-54954][PYTHON] Add overload stubs for remote_only [SPARK-54954][PYTHON] Fix remote related type hints in util.py Jan 8, 2026
@github-actions github-actions bot added the CORE label Jan 8, 2026
@gaogaotiantian
Copy link
Contributor Author

@HyukjinKwon , I updated this PR a bit because I realized that the original code mixed the concept of a SparkSession and a RemoteSparkSession - that's why it needs a lot of the type ignores - the object is different. I fixed the type hints with some minor assertion changes.

@HyukjinKwon
Copy link
Member

Merged to master.

Yicong-Huang pushed a commit to Yicong-Huang/spark that referenced this pull request Jan 9, 2026
### What changes were proposed in this pull request?

* Add overload stubs for `remote_only`.
* Distinguish remote and normal SparkSession
* Do some type assertions so we don't need all the ignore comments

### Why are the changes needed?

When we do something like
```python
property
remote_only
def method(self):
    ...
```

The latest version of mypy is not happy because it believes `remote_only` can return a `property`. We can't do `property` on a `property`.

By adding the explicit overload, mypy knows that `remote_only` always return a callable when given a callable.

### Does this PR introduce _any_ user-facing change?

No

### How was this patch tested?

Wait for CI.

### Was this patch authored or co-authored using generative AI tooling?

Generated-by: Cursor (claude-4.5-opus-high)

Closes apache#53722 from gaogaotiantian/fix-remote-only-overload.

Authored-by: Tian Gao <gaogaotiantian@hotmail.com>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants