Skip to content

typing: Re-pin & fix duckdb==1.4.1 #3188

@dangotbanned

Description

@dangotbanned

Upstream

Notes

Originally #3186 (comment)

It has a fix for this:

But mypy isn't happy:

Show mypy (19 errors)

narwhals/_utils.py:2078: error: Overloaded function signature 14 will never be matched: signature 8's parameter type(s) are the same or broader  [overload-cannot-match]
        def __get__(
        ^
narwhals/_utils.py:2082: error: Overloaded function signature 15 will never be matched: signature 8's parameter type(s) are the same or broader  [overload-cannot-match]   
        def __get__(self, instance: LazyFrame[Any], owner: Any) -> _LazyAllowedImpl: ...
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
narwhals/_namespace.py:298: error: Overloaded function signature 6 will never be matched: signature 5's parameter type(s) are the same or broader  [overload-cannot-match] 
        def from_native_object(cls, native: _NativeDask, /) -> Namespace[DaskNamespace]: ...
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
narwhals/_namespace.py:302: error: Overloaded function signature 7 will never be matched: signature 5's parameter type(s) are the same or broader  [overload-cannot-match] 
        def from_native_object(cls, native: _NativeIbis, /) -> Namespace[IbisNamespace]: ...
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
narwhals/_namespace.py:306: error: Overloaded function signature 8 will never be matched: signature 5's parameter type(s) are the same or broader  [overload-cannot-match] 
        def from_native_object(
        ^
narwhals/_namespace.py:312: error: Overloaded function signature 9 will never be matched: signature 5's parameter type(s) are the same or broader  [overload-cannot-match] 
        def from_native_object(
        ^
narwhals/_namespace.py:318: error: Overloaded function signature 10 will never be matched: signature 5's parameter type(s) are the same or broader  [overload-cannot-match]
        def from_native_object(
        ^
narwhals/_namespace.py:324: error: Overloaded function signature 11 will never be matched: signature 5's parameter type(s) are the same or broader  [overload-cannot-match]
        def from_native_object(
        ^
narwhals/_duckdb/group_by.py:32: error: Unused "type: ignore" comment  [unused-ignore]
                self.compliant.native.aggregate(agg_columns)  # type: ignore[arg-type]
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
narwhals/_duckdb/dataframe.py:181: error: Unused "type: ignore" comment  [unused-ignore]
                return self._with_native(self.native.aggregate(selection))  # type: ignore[arg-type]
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
narwhals/_duckdb/dataframe.py:258: error: Returning Any from function declared to return "DataFrame"  [no-any-return]
            return self.native.df()
            ^~~~~~~~~~~~~~~~~~~~~~~
narwhals/_duckdb/namespace.py:61: error: Unused "type: ignore" comment  [unused-ignore]
        def _function(self, name: str, *args: Expression) -> Expression:  # type: ignore[override]
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests/implementation_test.py:208: error: Unused "type: ignore" comment  [unused-ignore]
            any_ldf.collect(ldf_impl)  # type: ignore[arg-type]
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests/implementation_test.py:292: error: Unused "type: ignore" comment  [unused-ignore]
            any_df.lazy(df_impl)  # type: ignore[arg-type]
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests/implementation_test.py:296: error: Unused "type: ignore" comment  [unused-ignore]
            any_df.lazy(ser_impl)  # type: ignore[arg-type]
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests/namespace_test.py:84: error: Unused "type: ignore" comment  [unused-ignore]
            Namespace.from_native_object(data)  # type: ignore[call-overload]
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests/dtypes_test.py:422: error: Unused "type: ignore" comment  [unused-ignore]
                    nw.from_native(obj)  # type: ignore[call-overload]
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests/expr_and_series/is_close_test.py:117: error: Argument "backend" to "new_series" has incompatible type "Literal[Implementation.DUCKDB]"; expected
"Literal['pandas', 'cudf', 'modin', Implementation.PANDAS, Implementation.CUDF, Implementation.MODIN, 'pyarrow', Implementation.PYARROW, 'polars', Implementation.POLARS] | Module"  [arg-type]
            "nulls", [None] * len(x), nw.Float64(), backend=df.implementation
                                                            ^~~~~~~~~~~~~~~~~
tests/expr_and_series/is_close_test.py:141: error: Argument "backend" to "new_series" has incompatible type "Literal[Implementation.DUCKDB]"; expected
"Literal['pandas', 'cudf', 'modin', Implementation.PANDAS, Implementation.CUDF, Implementation.MODIN, 'pyarrow', Implementation.PYARROW, 'polars', Implementation.POLARS] | Module"  [arg-type]
            "nulls", [None] * len(y), nw.Float64(), backend=df.implementation
                                                            ^~~~~~~~~~~~~~~~~
Found 19 errors in 9 files (checked 437 source files)

And pyright was even shout-ier:

Show pyright (49 errors)

narwhals/_duckdb/dataframe.py
  narwhals/_duckdb/dataframe.py:145:17 - error: Argument of type "RecordBatchReader | Table" cannot be assigned to parameter "native_dataframe" of type "Table" in function "__init__"
    Type "RecordBatchReader | Table" is not assignable to type "Table"
      "RecordBatchReader" is not assignable to "Table" (reportArgumentType)
  narwhals/_duckdb/dataframe.py:420:38 - error: Argument of type "Literal[1]" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"     
    Type "Literal[1]" is not assignable to type "Expression | str"
      "Literal[1]" is not assignable to "Expression"
      "Literal[1]" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/dataframe.py:452:33 - error: Argument of type "int" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "int" is not assignable to type "Expression | str"
      "int" is not assignable to "Expression"
      "int" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/dataframe.py:489:13 - error: Argument of type "Literal[0]" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "Literal[0]" is not assignable to type "Expression | str"
      "Literal[0]" is not assignable to "Expression"
      "Literal[0]" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/dataframe.py:500:21 - error: Argument of type "None" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "None" is not assignable to type "Expression | str"
      "None" is not assignable to "Expression"
      "None" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/dataframe.py:545:77 - error: Argument of type "Literal[1]" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "Literal[1]" is not assignable to type "Expression | str"
      "Literal[1]" is not assignable to "Expression"
      "Literal[1]" is not assignable to "str" (reportArgumentType)
narwhals/_duckdb/expr.py
  narwhals/_duckdb/expr.py:127:31 - error: Argument of type "Literal[1]" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "Literal[1]" is not assignable to type "Expression | str"
      "Literal[1]" is not assignable to "Expression"
      "Literal[1]" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr.py:176:32 - error: Argument of type "Literal[2]" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "Literal[2]" is not assignable to type "Expression | str"
      "Literal[2]" is not assignable to "Expression"
      "Literal[2]" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr.py:177:50 - error: Argument of type "Literal[1]" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "Literal[1]" is not assignable to type "Expression | str"
      "Literal[1]" is not assignable to "Expression"
      "Literal[1]" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr.py:179:38 - error: Argument of type "Literal[0]" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "Literal[0]" is not assignable to type "Expression | str"
      "Literal[0]" is not assignable to "Expression"
      "Literal[0]" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr.py:179:46 - error: Argument of type "None" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "None" is not assignable to type "Expression | str"
      "None" is not assignable to "Expression"
      "None" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr.py:180:35 - error: Argument of type "Literal[1]" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "Literal[1]" is not assignable to type "Expression | str"
      "Literal[1]" is not assignable to "Expression"
      "Literal[1]" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr.py:180:43 - error: Argument of type "float" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "float" is not assignable to type "Expression | str"
      "float" is not assignable to "Expression"
      "float" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr.py:181:39 - error: Argument of type "Literal[2]" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "Literal[2]" is not assignable to type "Expression | str"
      "Literal[2]" is not assignable to "Expression"
      "Literal[2]" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr.py:181:47 - error: Argument of type "float" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "float" is not assignable to type "Expression | str"
      "float" is not assignable to "Expression"
      "float" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr.py:192:36 - error: Argument of type "Literal[2]" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "Literal[2]" is not assignable to type "Expression | str"
      "Literal[2]" is not assignable to "Expression"
      "Literal[2]" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr.py:193:54 - error: Argument of type "Literal[1]" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "Literal[1]" is not assignable to type "Expression | str"
      "Literal[1]" is not assignable to "Expression"
      "Literal[1]" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr.py:196:39 - error: Argument of type "Literal[0]" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "Literal[0]" is not assignable to type "Expression | str"
      "Literal[0]" is not assignable to "Expression"
      "Literal[0]" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr.py:196:47 - error: Argument of type "None" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "None" is not assignable to type "Expression | str"
      "None" is not assignable to "Expression"
      "None" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr.py:197:43 - error: Argument of type "Literal[1]" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "Literal[1]" is not assignable to type "Expression | str"
      "Literal[1]" is not assignable to "Expression"
      "Literal[1]" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr.py:197:51 - error: Argument of type "float" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "float" is not assignable to type "Expression | str"
      "float" is not assignable to "Expression"
      "float" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr.py:198:47 - error: Argument of type "Literal[2]" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "Literal[2]" is not assignable to type "Expression | str"
      "Literal[2]" is not assignable to "Expression"
      "Literal[2]" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr.py:198:55 - error: Argument of type "float" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "float" is not assignable to type "Expression | str"
      "float" is not assignable to "Expression"
      "float" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr.py:214:53 - error: Argument of type "float" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "float" is not assignable to type "Expression | str"
      "float" is not assignable to "Expression"
      "float" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr.py:234:47 - error: Argument of type "int" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "int" is not assignable to type "Expression | str"
      "int" is not assignable to "Expression"
      "int" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr.py:247:70 - error: Argument of type "int" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "int" is not assignable to type "Expression | str"
      "int" is not assignable to "Expression"
      "int" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr.py:261:70 - error: Argument of type "Sequence[Any]" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "Sequence[Any]" is not assignable to type "Expression | str"
      "Sequence[Any]" is not assignable to "Expression"
      "Sequence[Any]" is not assignable to "str" (reportArgumentType)
narwhals/_duckdb/expr_dt.py
  narwhals/_duckdb/expr_dt.py:30:75 - error: Argument of type "Literal[1000]" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "Literal[1000]" is not assignable to type "Expression | str"
      "Literal[1000]" is not assignable to "Expression"
      "Literal[1000]" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr_dt.py:35:75 - error: Argument of type "Literal[1000000]" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "Literal[1000000]" is not assignable to type "Expression | str"
      "Literal[1000000]" is not assignable to "Expression"
      "Literal[1000000]" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr_dt.py:40:74 - error: Argument of type "Literal[1000000000]" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "Literal[1000000000]" is not assignable to type "Expression | str"
      "Literal[1000000000]" is not assignable to "Expression"
      "Literal[1000000000]" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr_dt.py:61:30 - error: Argument of type "Literal[60]" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "Literal[60]" is not assignable to type "Expression | str"
      "Literal[60]" is not assignable to "Expression"
      "Literal[60]" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr_dt.py:67:30 - error: Argument of type "Literal[60000]" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "Literal[60000]" is not assignable to type "Expression | str"
      "Literal[60000]" is not assignable to "Expression"
      "Literal[60000]" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr_dt.py:73:30 - error: Argument of type "Literal[60000000]" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "Literal[60000000]" is not assignable to type "Expression | str"
      "Literal[60000000]" is not assignable to "Expression"
      "Literal[60000000]" is not assignable to "str" (reportArgumentType)
narwhals/_duckdb/expr_list.py
  narwhals/_duckdb/expr_list.py:26:47 - error: Argument of type "None" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "None" is not assignable to type "Expression | str"
      "None" is not assignable to "Expression"
      "None" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr_list.py:27:53 - error: Argument of type "None" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "None" is not assignable to type "Expression | str"
      "None" is not assignable to "Expression"
      "None" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr_list.py:34:55 - error: Argument of type "NonNestedLiteral" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "NonNestedLiteral" is not assignable to type "Expression | str"
      Type "Decimal" is not assignable to type "Expression | str"
        "Decimal" is not assignable to "Expression"
        "Decimal" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr_list.py:39:54 - error: Argument of type "int" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "int" is not assignable to type "Expression | str"
      "int" is not assignable to "Expression"
      "int" is not assignable to "str" (reportArgumentType)
narwhals/_duckdb/expr_str.py
  narwhals/_duckdb/expr_str.py:44:61 - error: Argument of type "Literal[1]" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "Literal[1]" is not assignable to type "Expression | str"
      "Literal[1]" is not assignable to "Expression"
      "Literal[1]" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/expr_str.py:45:46 - error: Argument of type "Literal[2]" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "Literal[2]" is not assignable to type "Expression | str"
      "Literal[2]" is not assignable to "Expression"
      "Literal[2]" is not assignable to "str" (reportArgumentType)
narwhals/_duckdb/namespace.py
  narwhals/_duckdb/namespace.py:132:58 - error: Argument of type "Literal[0]" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "Literal[0]" is not assignable to type "Expression | str"
      "Literal[0]" is not assignable to "Expression"
      "Literal[0]" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/namespace.py:145:29 - error: Argument of type "NonNestedLiteral" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "NonNestedLiteral" is not assignable to type "Expression | str"
      Type "Decimal" is not assignable to type "Expression | str"
        "Decimal" is not assignable to "Expression"
        "Decimal" is not assignable to "str" (reportArgumentType)
  narwhals/_duckdb/namespace.py:146:25 - error: Argument of type "NonNestedLiteral" cannot be assigned to parameter "value" of type "Expression | str" in function "ConstantExpression"
    Type "NonNestedLiteral" is not assignable to type "Expression | str"
      Type "Decimal" is not assignable to type "Expression | str"
        "Decimal" is not assignable to "Expression"
        "Decimal" is not assignable to "str" (reportArgumentType)
narwhals/_duckdb/utils.py
  narwhals/_duckdb/utils.py:67:29 - error: Argument of type "tuple[Expression] | str | tuple[Expression, ...]" cannot be assigned to parameter "lhs" of type "Expression | str | tuple[str]" in 
function "LambdaExpression"
    Type "tuple[Expression] | str | tuple[Expression, ...]" is not assignable to type "Expression | str | tuple[str]"
      Type "tuple[Expression, ...]" is not assignable to type "Expression | str | tuple[str]"
        "tuple[Expression, ...]" is not assignable to "Expression"
        "tuple[Expression, ...]" is not assignable to "str"
        "tuple[Expression, ...]" is not assignable to "tuple[str]"
          Tuple size mismatch; expected 1 but received indeterminate (reportArgumentType)
  narwhals/_duckdb/utils.py:151:52 - error: Argument of type "object" cannot be assigned to parameter "duckdb_dtype" of type "DuckDBPyType" in function "native_to_narwhals_dtype"
    "object" is not assignable to "DuckDBPyType" (reportArgumentType)
  narwhals/_duckdb/utils.py:159:29 - error: Type "list[object]" is not assignable to declared type "list[int]"
    "object" is not assignable to "int" (reportAssignmentType)
  narwhals/_duckdb/utils.py:161:24 - error: Cannot access attribute "id" for class "object"
    Attribute "id" is unknown (reportAttributeAccessIssue)
  narwhals/_duckdb/utils.py:162:36 - error: Cannot access attribute "children" for class "object"
    Attribute "children" is unknown (reportAttributeAccessIssue)
  narwhals/_duckdb/utils.py:165:42 - error: Argument of type "object | Unknown" cannot be assigned to parameter "duckdb_dtype" of type "DuckDBPyType" in function "native_to_narwhals_dtype"    
    Type "object | Unknown" is not assignable to type "DuckDBPyType"
      "object" is not assignable to "DuckDBPyType" (reportArgumentType)
  narwhals/_duckdb/utils.py:172:39 - error: Argument of type "object" cannot be assigned to parameter "categories" of type "Iterable[str] | type[Enum]" in function "__init__"
    Type "object" is not assignable to type "Iterable[str] | type[Enum]"
      "object" is incompatible with protocol "Iterable[str]"
        "__iter__" is not present
      Type "object" is not assignable to type "type[Enum]" (reportArgumentType)
49 errors, 0 warnings, 0 informations

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions