Skip to content

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

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

[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

@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

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