Skip to content

DuckDBPyRelation.write_{parquet, csv} lack keyword only marker in stubs #314

@OutSquareCapital

Description

@OutSquareCapital

What happens?

LSP warning for line 11 (to_csv() call):

Expected 1 positional argument

Nothing for line 10 (write_csv() call).
But if I try to run it, it will crash at line 10:

Traceback (most recent call last):
  File "C:\Users\tibo\python_codes\pql\t.py", line 15, in <module>
    main()
    ~~~~^^
  File "C:\Users\tibo\python_codes\pql\t.py", line 10, in main
    rel.write_csv(name, sep)
    ~~~~~~~~~~~~~^^^^^^^^^^^
TypeError: write_csv(): incompatible function arguments. The following argument types are supported:
    1. (self: _duckdb.DuckDBPyRelation, file_name: str, *, sep: object = None, na_rep: object = None, header: object = None, quotechar: object = None, escapechar: object = None, date_format: object = 
None, timestamp_format: object = None, quoting: object = None, encoding: object = None, compression: object = None, overwrite: object = None, per_thread_output: object = None, use_tmp_file: object = None, partition_by: object = None, write_partition_columns: object = None) -> None

Invoked with: ┌─────────┬───────┐
│   foo   │  bar  │
│ varchar │ int64 │
├─────────┼───────┤
│ a       │     1 │
└─────────┴───────┘
, 'foo.csv', ','

The solution would be to simply copy-past the signature from to_{csv, parquet} to their respective write_ aliases.

To Reproduce

import duckdb
import polars as pl


def main() -> None:
    name = "foo.csv"
    sep = ","

    rel = pl.DataFrame({"foo": ["a"], "bar": [1]}).pipe(duckdb.from_arrow)
    rel.write_csv(name, sep)
    rel.to_csv(name, sep)


if __name__ == "__main__":
    main()

OS:

Windows

DuckDB Package Version:

1.4.4

Python Version:

3.13.7

Full Name:

Stettler Thibaud

Affiliation:

None

What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.

I have not tested with any build

Did you include all relevant data sets for reproducing the issue?

Yes

Did you include all code required to reproduce the issue?

  • Yes, I have

Did you include all relevant configuration to reproduce the issue?

  • Yes, I have

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions