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

Frozen Pydantic BaseModel's and frozen dataclasses don't work together #1886

Open
DanielNoord opened this issue Nov 23, 2022 · 0 comments
Open

Comments

@DanielNoord
Copy link
Collaborator

Steps to reproduce

from dataclasses import dataclass

from pydantic import BaseModel


class FrozenPydanticModel(BaseModel):
    class Config:
        frozen = True


@dataclass(frozen=True)
class FrozenDataclass:
    pass


class CombinedDataclassModel(FrozenPydanticModel, FrozenDataclass):
    attr: int


CombinedDataclassModel(attr=1)

This raises an unexpected keyword argument in pylint for attr. This is because astroid doesn't build the __init__ of CombinedDataclassModel correctly.

Expected behavior

Set attr as an expected argument in the __init__ of CombinedDataclassModel. This is because the frozen BaseModel allows this pattern.

Version: 2.12.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant