ty
ty copied to clipboard
Conversion of `collections.abc.Collection[str] & ~AlwaysFalsy` to `set()` results in `set[Unknown]` instead of `set[str]`
Summary
This builds upon the issue raised in: https://github.com/astral-sh/ty/issues/2060
The MRE I supplied of the real-world code elided a Falsey check, which does seem to disrupt the fix that was made for https://github.com/astral-sh/ty/issues/2060
https://play.ty.dev/f980f01d-288a-48cc-a04a-759f80d74b9d
from collections.abc import Collection
from typing import Mapping, reveal_type
def something(mapping: Collection[str] | None = None):
if not mapping:
raise ValueError
reveal_type(mapping) # Collection[str] & ~AlwaysFalsy
mapping = set(mapping)
reveal_type(mapping) # set[Unknown]
Version
0.0.6