Skip to content

Conversation

grihabor
Copy link

@grihabor grihabor commented Jun 5, 2025

What changes were proposed in this pull request?

Better type hints for SparkConf class for mypy and other python type checkers

Why are the changes needed?

Right now SparkConf accepts any iterable, but the type annotation says it only accepts a list, so the following code works at runtime, but fails in mypy:

from pyspark.conf import SparkConf

d = {"a": "b"}
SparkConf().setAll(d.items())

mypy output:

tmp.py:4: error: Argument 1 to "setAll" of "SparkConf" has incompatible type "dict_items[str, str]"; expected "list[tuple[str, str]]"  [arg-type]
Found 1 error in 1 file (checked 1 source file)

Does this PR introduce any user-facing change?

No

How was this patch tested?

Manually, by running mypy

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

No

grihabor added 2 commits June 5, 2025 20:12
Right now SparkConf accepts any iterable, but the type annotation says
it only accepts list of tuples, so the following code works at runtime,
but fails in mypy:

```python
from pyspark.conf import SparkConf

d = {"a": "b"}
SparkConf().setAll(d.items())
```
mypy output:
```
tmp.py:4: error: Argument 1 to "setAll" of "SparkConf" has incompatible type "dict_items[str, str]"; expected "list[tuple[str, str]]"  [arg-type]
Found 1 error in 1 file (checked 1 source file)
```
Copy link

We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
If you'd like to revive this PR, please reopen it and ask a committer to remove the Stale tag!

@github-actions github-actions bot added the Stale label Sep 14, 2025
@github-actions github-actions bot closed this Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant