Describe the bug
I expect an "Unresolved attribute reference" warning when I reference a Pydantic model attribute that does not exist. I am not getting one. I do get a warning when I create the same object with as a dataclass. I've gotten multiple failures at runtime because of this, when I would have expected to get the warning at coding time in my IDE.
To Reproduce
Code example:
from dataclasses import dataclass
from pydantic import BaseModel
@dataclass
class DataclassExample:
value: int
dataclass_example = DataclassExample(value=42)
print(dataclass_example.value) # No warning.
print(dataclass_example.nonvalue) # Unresolved attribute reference 'nonvalue' for class 'DataclassExample'
class PydanticExample(BaseModel):
value: int
pydantic_example = PydanticExample(value=42)
print(pydantic_example.value) # No warning.
print(pydantic_example.nonvalue) # No warning, but should give one.
Expected behavior
I expect the nonvalue
attribute of the pydantic model to be underlined with the same warning "Unresolved attribute reference" as when I create a dataclass.
Screenshots
Environments (please complete the following information):
Additional context
No more context needed.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too