Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#90 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
api

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
247
フォーク
66
平均マージ
22時間 47分
マージ済み PR(30日)
8

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

typesense/typesense-python のほかの issue

typesense/typesense-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。