You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Tobias Edwards (Jira)" <ji...@apache.org> on 2021/07/20 03:27:00 UTC

[jira] [Created] (SPARK-36220) Incorrect pyspark.sql.types.Row __new__ and __init__ type annotations

Tobias Edwards created SPARK-36220:
--------------------------------------

             Summary: Incorrect pyspark.sql.types.Row __new__ and __init__ type annotations
                 Key: SPARK-36220
                 URL: https://issues.apache.org/jira/browse/SPARK-36220
             Project: Spark
          Issue Type: Bug
          Components: PySpark
    Affects Versions: 3.1.2
            Reporter: Tobias Edwards


This bug involves incorrect type annotations for {{pyspark.sql.types.Row}}'s {{\_\_new\_\_}} and {{\_\_init\_\_}} methods when invoked without keyword arguments (_i.e._, {{\*args}} rather than {{\*\*kwargs}}).

When creating a [Row|https://hyukjin-spark.readthedocs.io/en/latest/reference/api/pyspark.sql.types.Row.html] with unnamed fields which are not of type {{str}} (_e.g._, {{row1 = Row("Alice", 11)}} appears in the {{Row}} documentation) type checkers produce an error.

The implementation doesn't assume the arguments are of type {{str}}, and in fact the documentation includes an example where non-{{str}} types are provided in this way (see [the final example here|https://hyukjin-spark.readthedocs.io/en/latest/reference/api/pyspark.sql.types.Row.html]).

An example of the type error produced by [pyright|https://github.com/microsoft/pyright] is

{code}
error: No overloads for "__init__" match the provided arguments
    Argument types: (Literal['Alice'], Literal[11]) (reportGeneralTypeIssues)
{code}




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org