1. [SPARK-36211][PYTHON] Correct typing of `udf` return value (details)
Commit 682b306f8bbbbe189ec7f2b8179b16741adad396 by mszymkiewicz
[SPARK-36211][PYTHON] Correct typing of `udf` return value

The following code should type-check:

import uuid

import pyspark.sql.functions as F

my_udf = F.udf(lambda: str(uuid.uuid4())).asNondeterministic()

### What changes were proposed in this pull request?

The `udf` function should return a more specific type.

### Why are the changes needed?

Right now, `mypy` will throw spurious errors, such as for the code given above.

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


### How was this patch tested?

This was not tested. Sorry, I am not very familiar with this repo -- are there any typing tests?

Closes #33399 from luranhe/patch-1.

Lead-authored-by: Luran He <>
Co-authored-by: Luran He <>
Signed-off-by: zero323 <>
(cherry picked from commit ede1bc6b51c23b2d857b497d335b8e7fe3a5e0cc)
Signed-off-by: zero323 <>
The file was modifiedpython/pyspark/sql/functions.pyi (diff)
The file was modifiedpython/pyspark/sql/_typing.pyi (diff)