[types] incomptabile assignment types due to invariant and type union
まだ誰も着手していません。
評価
調査の方向性
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 を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
typesense/typesense-python のほかの issue
-
`MultiSearchResponse` type does not account for union search response shape対応中かも @tharropoulos が 172 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
typesense/typesense-python#128 ·
-
`documents.Documents.import_()` `batch_size` argument is ignored, type of `import_parameters` is missing `batch_size`対応中かも @tharropoulos が 245 日前に担当しました。 オープン
難易度 2/5 1〜2日 初心者へのやさしさ 68/100
typesense/typesense-python#124 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
typesense/typesense-python#100 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
typesense/typesense-python#122 · コメント 3 件 ·
-
[Bug] - DeprecationWarning on instantiation of Client対応中かも @tharropoulos が 266 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
typesense/typesense-python#114 · コメント 8 件 ·
typesense/typesense-python の issue をすべて見る
似ている issue
-
type-bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
push_gh-pages fails on master branch on forks対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンgood first issue infrastructure
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
kuznia-rdzeni/coreblocks#1135 ·
-
good first issue server
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
documentation priority: high
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
a-lex-s/mealie-telegram-bot#54 ·
メンテナーはふだん 1 日以内に返信