Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[types] incomptabile assignment types due to invariant and type union

Abierto
#90 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
python
Área
api

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

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de typesense/typesense-python

Todos los issues de typesense/typesense-python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.