[types] incomptabile assignment types due to invariant and type union
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Start with the type definitions in src/typesense/types/collection.py around lines 226-232, then trace the definitions used by CollectionUpdateSchema and RegularCollectionFieldSchema. Reproduce the reported assignment with a type checker and verify that a list containing only RegularCollectionFieldSchema is accepted without requiring reverse engineering of the internal union type.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Instead of using type unions (like used here https://github.com/typesense/typesense-python/blob/master/src/typesense/types/collection.py#L226-L232), the library should use bound typevar like:
a: list[int | str]
b: list[int] = [1]
a = b # failure: incompatible assignment due to invariant
from typing import TypeVar
ListT = TypeVar("ListT", bound=int | str)
c: list[ListT]
d: list[int] = [1]
e: list[str] = ["a"]
f: list[int | str] = [1, "a"]
c = d # success
c = e # success
c = f # success
The type checkers are really unhappy with the way that the types are currently formulated. I should be able to supply a list of just RegularCollectionFieldSchema to CollectionUpdateSchema. Instead it errors due to the type construction. I shouldn't have to reverse engineer the internal union type to satisfy the type checker.
- Lingua principale
- Python
- Stelle
- 247
- Fork
- 68
- Merge medio
- 22h 47m
- PR unite (30g)
- 8
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di typesense/typesense-python
-
`MultiSearchResponse` type does not account for union search response shapeForse già presa @tharropoulos l’ha presa 175 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
typesense/typesense-python#128 ·
-
`documents.Documents.import_()` `batch_size` argument is ignored, type of `import_parameters` is missing `batch_size`Forse già presa @tharropoulos l’ha presa 248 giorni fa. Aperta
Difficoltà 2/5 1-2 giorni Idoneità per principianti 68/100
typesense/typesense-python#124 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
typesense/typesense-python#100 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
typesense/typesense-python#122 · 3 commenti ·
-
[Bug] - DeprecationWarning on instantiation of ClientForse già presa @tharropoulos l’ha presa 269 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
typesense/typesense-python#114 · 8 commenti ·
Tutte le issue di typesense/typesense-python
Issue simili
-
Link Checker ReportApertaautomated issue linkchecker report
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
QuantEcon/lecture-python.myst#1098 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
podly-pure-podcasts/podly_pure_podcasts#279 ·
I maintainer di solito rispondono entro 1 giorno
-
New template proposal: ljpApertatemplate-proposal
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
OpenShot/openshot-qt#6230 ·
I maintainer di solito rispondono entro 1 giorno