Incorrect narrowing after `TypeIs[type[...]]` check
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 53/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 領域
- devtools, testing-qa
調査の方向性
Start by reproducing the narrowing behavior in the linked Pyrefly sandbox, then trace how custom TypeIs predicates narrow both branches in the Rust type checker. Compare the TypeIs[type[bytes]] example with the built-in issubclass example and find the relevant narrowing tests. Done means the else branch retains the appropriate type instead of becoming Never, with regression coverage for the example.
索引モデルが issue の本文から書いたものです。
説明
Describe the Bug
narrowing with a custom -> TypeIs[type[Foo]] incorrectly narrows the else branch to Never:
from typing import TypeIs, reveal_type
def is_bytes(obj: object, /) -> TypeIs[type[bytes]]:
return isinstance(obj, type) and issubclass(obj, bytes)
def check(cls: type, /) -> None:
if is_bytes(cls):
reveal_type(cls) # type[bytes]
else:
reveal_type(cls) # Never
def check2(cls: type, /) -> None:
if issubclass(cls, bytes):
reveal_type(cls) # type[bytes]
else:
reveal_type(cls) # type[Any]
Sandbox Link
(Only applicable for extension issues) IDE Information
No response
- 主要言語
- Rust
- スター
- 7.2k
- フォーク
- 578
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
facebook/pyrefly のほかの issue
-
pytorch tensor-shapes typechecking
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
good first issue typechecking
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
cargo b warning: unused dependency `zstd`対応中かも @Narendersingh007 が 4 日前に担当しました。 オープンgood first issue
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
-
pydantic
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
facebook/pyrefly の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
eventflux-io/eventflux#203 ·
メンテナーはふだん 1 日以内に返信
-
bug ui
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
userFRM/egui-charts#4068 ·
メンテナーはふだん 1 日以内に返信
-
fuzz-crash review-followup
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
marketing
難易度 2/5 半日 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
aws/aws-emulator#610 ·