Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Nov 7, 2024

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
16 checks passed
@sharkdp sharkdp deleted the david/fix-intersection-type-explanation branch November 7, 2024 20:23
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 red-knot 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
red-knot Multi-file analysis & type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants