Skip to content

[red-knot] Minor fix in intersection type comment#14176

Merged
sharkdp merged 1 commit intomainfrom
david/fix-intersection-type-explanation
Nov 7, 2024
Merged

[red-knot] Minor fix in intersection type comment#14176
sharkdp merged 1 commit intomainfrom
david/fix-intersection-type-explanation

Conversation

@sharkdp
Copy link
Contributor

@sharkdp sharkdp commented Nov 7, 2024

Summary

Minor fix in intersection type comment introduced in #14138

@sharkdp sharkdp force-pushed the david/fix-intersection-type-explanation branch from a80d930 to ee871d4 Compare November 7, 2024 20:18
//
// However, we do have to leave out the negative contributions. If we were to
// add a contribution like ~f(N1), we would potentially infer result types
// that are too narrow, since ~f(A) can be larger than f(~A).
Copy link
Contributor Author

@sharkdp sharkdp Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better not to talk about the size of ~f(A). We should rather compare f(A & ~B) with f(A) & ~f(B). The former can be larger (bool) than the latter (Literal[True]), as demonstrated in the example below.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is the part I was having the hardest time thinking through clearly

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fully worked example makes it much clearer

@sharkdp sharkdp enabled auto-merge (squash) November 7, 2024 20:21
@sharkdp sharkdp merged commit 5b6169b into main Nov 7, 2024
@sharkdp sharkdp deleted the david/fix-intersection-type-explanation branch November 7, 2024 20:23
@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@dhruvmanila dhruvmanila added the ty Multi-file analysis & type inference label Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants