Internal Type Inference #5686
-
Hi @charliermarsh 👋 I'm building bump-pydantic, and I was wondering if you can help me. You don't do any kind of type inference on I want to refactor the following code: from pydantic import BaseModel
class Model(BaseModel):
a: int
model = Model(a=1)
model.dict() # change this to `model.model_dump()` I want to make sure that Do you do something like that in |
Beta Was this translation helpful? Give feedback.
Answered by
charliermarsh
Jul 11, 2023
Replies: 1 comment 2 replies
-
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() |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
Kludex
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
This is also harder: