# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: proto3_field_presence_oneof.proto
# plugin: python-betterproto
# This file has been @generated

from typing import TYPE_CHECKING


if TYPE_CHECKING:
    from dataclasses import dataclass
else:
    from pydantic.dataclasses import dataclass

from typing import Optional

import betterproto
from pydantic import model_validator
from pydantic.dataclasses import rebuild_dataclass


@dataclass(eq=False, repr=False)
class Test(betterproto.Message):
    nested: Optional["Nested"] = betterproto.message_field(
        1, optional=True, group="kind"
    )
    with_optional: Optional["WithOptional"] = betterproto.message_field(
        2, optional=True, group="kind"
    )

    @model_validator(mode="after")
    def check_oneof(cls, values):
        return cls._validate_field_groups(values)


@dataclass(eq=False, repr=False)
class InnerNested(betterproto.Message):
    a: Optional[bool] = betterproto.bool_field(1, optional=True)


@dataclass(eq=False, repr=False)
class Nested(betterproto.Message):
    inner: "InnerNested" = betterproto.message_field(1)


@dataclass(eq=False, repr=False)
class WithOptional(betterproto.Message):
    b: Optional[bool] = betterproto.bool_field(2, optional=True)


rebuild_dataclass(Test)  # type: ignore
rebuild_dataclass(Nested)  # type: ignore
