[ty] do not union Unknown into unannotated container types by carljm · Pull Request #23718 · astral-sh/ruff (original) (raw)

@carljm added the ty

Multi-file analysis & type inference

label

Mar 4, 2026

@carljm

@carljm

@carljm carljm marked this pull request as ready for review

March 5, 2026 00:23

charliermarsh

dcreager

@carljm

@carljm carljm deleted the cjm/remove-container-literal-unknown branch

March 5, 2026 23:40

carljm added a commit that referenced this pull request

Mar 6, 2026

@carljm

Summary

Avoid inferring invariant container types like list[int & ~AlwaysFalsy], preferring list[int] instead.

Also generally rename "literal promotion" to just "promotion" -- it already promoted e.g. float to int | float, so it wasn't restricted to literal types. Now it includes even more non-literal cases.

Test Plan

Added an mdtest.

Removes ~200 ecosystem hits from #23718

KotlinIsland pushed a commit to KotlinIsland/basedpython that referenced this pull request

May 1, 2026

@carljm

Summary

Avoid inferring invariant container types like list[int & ~AlwaysFalsy], preferring list[int] instead.

Also generally rename "literal promotion" to just "promotion" -- it already promoted e.g. float to int | float, so it wasn't restricted to literal types. Now it includes even more non-literal cases.

Test Plan

Added an mdtest.

Removes ~200 ecosystem hits from astral-sh/ruff#23718

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})