Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-36220

Incorrect pyspark.sql.types.Row __new__ and __init__ type annotations

    XMLWordPrintableJSON

Details

    • Bug
    • Status: In Progress
    • Minor
    • Resolution: Unresolved
    • 3.1.2
    • None
    • PySpark
    • None

    Description

      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 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).

      An example of the type error produced by pyright is

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

      Attachments

        Activity

          People

            Unassigned Unassigned
            tobiasedwards Tobias Edwards
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: