[ty] fix nested `NewType`s with add `Type::as_union_like`
This method was part of my implementation of
https://github.com/astral-sh/ty/issues/1656, but I found a bug in nested
`NewType`s of (surprise) `float` and `complex` that could be fixed by
landing it separately, so I want to factor it out into its own PR.
[ty] Support finding dependencies in system Pythons that ty is installed into
Fixes an issue where ty couldn't resolve imports from packages installed
in a system Python environment when ty itself was installed directly in
that system Python (rather than in a virtual environment).
Previously, `SysPrefixPathOrigin::SelfEnvironment` was treated as requiring
a virtual environment (with `pyvenv.cfg`), which caused discovery to fail
for system Python installations. This change allows ty to fall back to
treating its own environment as a `SystemEnvironment` when no `pyvenv.cfg`
is found.
Additionally, this change implements correct priority ordering:
- When ty is installed in a virtual environment (e.g., `uvx --with ...`),
ty's venv takes priority over other discovered environments
- When ty is installed in a system Python, discovered environments (like
`.venv`) take priority over the system Python's site-packages
Fixes https://github.com/astral-sh/ty/issues/2068
https://claude.ai/code/session_01885t5j7zeT78vRZCtu8X9C
[ty] Make filter_union internally expand TypeAlias
This change modifies `filter_union` to resolve type aliases before
checking if the type is a union. This allows `filter_union` to properly
handle cases where a type alias resolves to a union type.
With this change, the explicit `resolve_type_alias` call in `bind.rs`
(added in #22988) is now redundant and has been removed.
Added additional test cases for union type aliases with:
- TypedDict dict literal inference
- TypedDict dict() call inference
- Set literal inference
https://claude.ai/code/session_01Fsp2dSw6mnTBV1M2Fnf6gt