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] understand the Literal[] special form in annotations #13672

Open
carljm opened this issue Oct 7, 2024 · 2 comments
Open

[red-knot] understand the Literal[] special form in annotations #13672

carljm opened this issue Oct 7, 2024 · 2 comments
Assignees
Labels
red-knot Multi-file analysis & type inference

Comments

@carljm
Copy link
Contributor

carljm commented Oct 7, 2024

No description provided.

@carljm carljm added the red-knot Multi-file analysis & type inference label Oct 7, 2024
@MichaReiser
Copy link
Member

This is to teach red knot that mode is a union over w or r for def open(mode: Literal["w", "r"])

@carljm
Copy link
Contributor Author

carljm commented Oct 9, 2024

This is to teach red knot that mode is a union over w or r for def open(mode: Literal["w", "r"])

In order to fully handle this particular case, we will also have to implement #13693. But that issue isn't a blocker for this one. If we implement inference of Literal in type annotations (this issue) such that we understand this case which doesn't have the annotation on a function parameter:

from typing import Literal

x: Literal[10] = 10

def f():
    # currently we reveal `@Todo` here
    reveal_type(x)  # revealed: Literal[10]

then the parameter-annotation case @MichaReiser described will fall out naturally from #13693

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

No branches or pull requests

2 participants