duckdb / duckdb/duckdb-python

`read_json` accepts a list of paths at runtime but the type stub only allows a single path.

Abierto Apto para principiantes
#576 1 comentario 0 reacciones 0 asignados Ver en GitHub
needs triage
Lenguaje dominante
Python
Estrellas
186
Forks
113
Merge medio
13 h 29 min
PR fusionados (30 d)
17

Descripción

### What happens?

Hi duckdb team, big fan of the product!

I'm experiencing a small typing issue:

```python
import duckdb

con = duckdb.connect()
rel = con.read_json(
["a.jsonl", "b.jsonl"],
format="newline_delimited",
)
print(rel.count("*").fetchone())
```

This runs fine and returns the union of both files.

However, pyright throws:
`Argument of type "list[str]" cannot be assigned to parameter "path_or_buffer" of type "str | bytes | PathLike[str] | PathLike[bytes] | IO[bytes] | IO[str]"`

mypy throws a similar error.

Adding `list[str]` (and probably `list[PathLike]`) to `path_or_buffer` in the Python stub would fix this

### To Reproduce

```python
import duckdb

con = duckdb.connect()
rel = con.read_json(
["a.jsonl", "b.jsonl"],
format="newline_delimited",
)
print(rel.count("*").fetchone())
```

### OS:

macOS arm64

### DuckDB Package Version:

1.5.3

### Python Version:

3.10

### Full Name:

Amir Refaee

### Affiliation:

Railtracks

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

I have tested with a stable release

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

Not applicable - the reproduction does not require a data set

### Did you include all code required to reproduce the issue?

- [x] Yes, I have

### Did you include all relevant configuration to reproduce the issue?

- [x] Yes, I have

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza localizando el stub de Python para con.read_json e inspecciona la anotación de path_or_buffer. Comprueba la reproducción con pyright y mypy; se considera terminado cuando ambos comprobadores de tipos aceptan listas de rutas JSON, mientras que las formas existentes de una sola ruta siguen siendo válidas.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
developer-experience
Tipo de issue
Error
Dificultad
2/5
Tiempo estimado
1-3 horas
Estado de actividad
Tranquilo
Claridad
Bien especificado
Aptitud para principiantes
78/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.