Skip to content

[SPARK-54993][PYTHON] Add type hints to NameTypeHolder and IndexNameTypeHolder classes#55807

Closed
adith-os wants to merge 1 commit into
apache:masterfrom
adith-os:SPARK-54993-improve-typehints
Closed

[SPARK-54993][PYTHON] Add type hints to NameTypeHolder and IndexNameTypeHolder classes#55807
adith-os wants to merge 1 commit into
apache:masterfrom
adith-os:SPARK-54993-improve-typehints

Conversation

@adith-os
Copy link
Copy Markdown
Contributor

@adith-os adith-os commented May 11, 2026

What changes were proposed in this pull request?

This PR adds proper type annotations to the NameTypeHolder and IndexNameTypeHolder classes in python/pyspark/pandas/typedef/typehints.py

Why are the changes needed?

This is a subtask of SPARK-54953 (upgrading mypy to latest version). Changes improve type checking.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Errors on typehints.py before Changes (delete # type: ignore[assignment]):

starting mypy annotations test...
annotations failed mypy checks:
python/pyspark/pandas/typedef/typehints.py:729: error: Incompatible types in assignment (expression has type "ExtensionDtype", variable has type "None")  [assignment]
python/pyspark/pandas/typedef/typehints.py:896: error: Incompatible types in assignment (expression has type "ExtensionDtype", variable has type "None")  [assignment]
python/pyspark/pandas/typedef/typehints.py:900: error: Incompatible types in assignment (expression has type "type[Any] | Any", variable has type "None")  [assignment]
python/pyspark/pandas/typedef/typehints.py:917: error: Incompatible types in assignment (expression has type "ExtensionDtype", variable has type "None")  [assignment]
python/pyspark/pandas/typedef/typehints.py:920: error: Incompatible types in assignment (expression has type "type[Any] | Any", variable has type "None")  [assignment]

After changes:
Verified with mypy that typehints.py has no type errors

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

Generated-by: Github Copilot GPT 5.2-Codex

@zhengruifeng
Copy link
Copy Markdown
Contributor

@gaogaotiantian

zhengruifeng pushed a commit that referenced this pull request May 13, 2026
…ypeHolder classes

### What changes were proposed in this pull request?
This PR adds proper type annotations to the NameTypeHolder and IndexNameTypeHolder classes in python/pyspark/pandas/typedef/typehints.py

### Why are the changes needed?
This is a subtask of [ SPARK-54953](https://issues.apache.org/jira/browse/SPARK-54953) (upgrading mypy to latest version). Changes improve type checking.

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

### How was this patch tested?
Errors on typehints.py before Changes (delete `# type: ignore[assignment]`):
```
starting mypy annotations test...
annotations failed mypy checks:
python/pyspark/pandas/typedef/typehints.py:729: error: Incompatible types in assignment (expression has type "ExtensionDtype", variable has type "None")  [assignment]
python/pyspark/pandas/typedef/typehints.py:896: error: Incompatible types in assignment (expression has type "ExtensionDtype", variable has type "None")  [assignment]
python/pyspark/pandas/typedef/typehints.py:900: error: Incompatible types in assignment (expression has type "type[Any] | Any", variable has type "None")  [assignment]
python/pyspark/pandas/typedef/typehints.py:917: error: Incompatible types in assignment (expression has type "ExtensionDtype", variable has type "None")  [assignment]
python/pyspark/pandas/typedef/typehints.py:920: error: Incompatible types in assignment (expression has type "type[Any] | Any", variable has type "None")  [assignment]
```
After changes:
Verified with mypy that typehints.py has no type errors

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

Generated-by: Github Copilot GPT 5.2-Codex

Closes #55807 from adith-os/SPARK-54993-improve-typehints.

Authored-by: adith-os <194981725+adith-os@users.noreply.github.com>
Signed-off-by: Ruifeng Zheng <ruifengz@foxmail.com>
(cherry picked from commit 7d245ea)
Signed-off-by: Ruifeng Zheng <ruifengz@foxmail.com>
@zhengruifeng
Copy link
Copy Markdown
Contributor

merged to master/4.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants