A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pydantic/pydantic/issues/1668 below:

Inherited dataclasses don't resolve forward refs · Issue #1668 · pydantic/pydantic · GitHub

Bug
pydantic version: 1.5.1
python version: 3.8.2

a.py:

from __future__ import annotations
from uuid import UUID
from pydantic.dataclasses import dataclass

@dataclass
class A:
    uuid: UUID

    # workaround
    # def __post_init__(self):
    #     self.__pydantic_model__.update_forward_refs(**globals())

b.py:

from __future__ import annotations
from uuid import uuid4
from pydantic.dataclasses import dataclass
from a import A

@dataclass
class B(A):
    pass

B(uuid=uuid4())

B(uuid=uuid4()) throws field "uuid" not yet prepared so type is still a ForwardRef, you might need to call B.update_forward_refs().


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4