[types] incomptabile assignment types due to invariant and type union
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 247
- Forks
- 66
- Merge medio
- 22 h 47 min
- PR fusionados (30 d)
- 8
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de typesense/typesense-python
-
`MultiSearchResponse` type does not account for union search response shapePosiblemente ocupada @tharropoulos la tomó hace 172 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
typesense/typesense-python#128 ·
-
`documents.Documents.import_()` `batch_size` argument is ignored, type of `import_parameters` is missing `batch_size`Posiblemente ocupada @tharropoulos la tomó hace 245 días. Abierto
Dificultad 2/5 1-2 días Aptitud para principiantes 68/100
typesense/typesense-python#124 ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
typesense/typesense-python#100 ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
typesense/typesense-python#122 · 3 comentarios ·
-
[Bug] - DeprecationWarning on instantiation of ClientPosiblemente ocupada @tharropoulos la tomó hace 266 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
typesense/typesense-python#114 · 8 comentarios ·
Todos los issues de typesense/typesense-python
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
AstrBotDevs/AstrBot#10720 ·
Los mantenedores suelen responder en 1 día
-
fix(xiaomi): curated picker list still offers six ids that return 400 (plan-limited vs retired)Abiertocause/upstream comp/cli P2 provider/other tool/file type/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
NousResearch/hermes-agent#143900 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 85/100
WLAN-Pi/wlanpi-profiler#341 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
Los mantenedores suelen responder en 1 día