Describe the bug
According to the example I posted below, dacite provides information that the returned object is a Base instance, not a User. At least that's how it looks from a pylint perspective (mypy doesn't report any errors). Technically, the code below still works, but there were no warnings/errors when version 1.7.0 was used.
To Reproduce
from __future__ import annotations
from dataclasses import dataclass
from typing import Type, TypeVar
from dacite import from_dict
from dacite.data import Data
T = TypeVar("T")
@dataclass
class Base:
@classmethod
def from_dict(cls: Type[T], data: Data) -> T:
return from_dict(data_class=cls, data=data)
@dataclass
class User(Base):
name: str
user = User.from_dict({"name": "John"})
print(user.name) # E1101: Instance of 'Base' has no 'name' member (no-member)
Expected behavior
No pylint errors as it was in version 1.7.0.
Environment
Python version: 3.8.10
dacite version: 1.8.1
pylint version: 2.17.4
Additional context
We implemented such a "base" dataclass a long time ago. And maybe it is not the best piece of the code but it forces us to use the from_dict() function always the same way, no matter which class we talk about (consistency).
In the near future, we plan to upgrade our code to Python 3.11, then, I will verify it once again. But if I find some free time for open-source coding in the meantime, I will try to debug it on my own 😉
Describe the bug According to the example I posted below,
dacite
provides information that the returned object is aBase
instance, not aUser
. At least that's how it looks from apylint
perspective (mypy
doesn't report any errors). Technically, the code below still works, but there were no warnings/errors when version 1.7.0 was used.To Reproduce
Expected behavior No
pylint
errors as it was in version 1.7.0.Environment
dacite
version: 1.8.1pylint
version: 2.17.4Additional context We implemented such a "base" dataclass a long time ago. And maybe it is not the best piece of the code but it forces us to use the
from_dict()
function always the same way, no matter which class we talk about (consistency).In the near future, we plan to upgrade our code to Python 3.11, then, I will verify it once again. But if I find some free time for open-source coding in the meantime, I will try to debug it on my own 😉