Skip to content

Internal Type Inference #5686

Answered by charliermarsh
Kludex asked this question in Q&A
Jul 11, 2023 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Yeah, we don't do this in Ruff right now. Our semantic model has enough information that we could support a rewrite in some cases like the one above, but there's a sliding scale of complexity, e.g. this is harder:

def f(x: int) -> Any:
  return Model(a=1)

model = f()
model.dict()

This is also harder:

from other_module import Model

model = Model(a=1)
model.dict()

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Kludex
Comment options

@charliermarsh
Comment options

Answer selected by Kludex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants