Python client type hint error with column-oriented upsert
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.4k
- Forks
- 301
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 37
Description
I'm trying to do an upsert without hard-coded data and I get some type hint errors. Everything works fine so I'm assuming its just a typing issue.
The error on ids is:
Pyright: Argument of type "list[int]" cannot be assigned to parameter "ids" of type "List[ExtendedPointId]" in function "__init__"
"list[int]" is not assignable to "List[ExtendedPointId]"
Type parameter "_T@list" is invariant, but "int" is not the same as "ExtendedPointId"
Consider switching from "list" to "Sequence" which is covariant
I can fix this one by typing the ids declaration as ids: list[ExtendedPointId]. This may be just a pyright issue since ExtendedPointId is defined as int | str.
The error on vectors is:
Pyright: Argument of type "Iterable[ndarray[Unknown, Unknown]]" cannot be assigned to parameter "vectors" of type "BatchVectorStruct" in function "__init__"
Type "Iterable[ndarray[Unknown, Unknown]]" is not assignable to type "BatchVectorStruct"
"Iterable[ndarray[Unknown, Unknown]]" is not assignable to "List[List[StrictFloat]]"
"Iterable[ndarray[Unknown, Unknown]]" is not assignable to "List[List[List[StrictFloat]]]"
"Iterable[ndarray[Unknown, Unknown]]" is not assignable to "Dict[StrictStr, List[Vector]]"
Can't seem to get around this one without a cast. Like I said, everything works but the type errors hamper the DX.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the Python client's column-oriented upsert entry point and inspect the type definitions for ids and vectors used by its constructor. Reproduce the Pyright diagnostics with list[int] and an iterable of ndarrays; done means valid caller inputs type-check without casts while preserving the working upsert behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, developer-experience
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100