# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: oneof_empty.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 Nothing(betterproto.Message):
    pass


@dataclass(eq=False, repr=False)
class MaybeNothing(betterproto.Message):
    sometimes: str = betterproto.string_field(42)


@dataclass(eq=False, repr=False)
class Test(betterproto.Message):
    nothing: Optional["Nothing"] = betterproto.message_field(
        1, optional=True, group="empty"
    )
    maybe1: Optional["MaybeNothing"] = betterproto.message_field(
        2, optional=True, group="empty"
    )
    maybe2: Optional["MaybeNothing"] = betterproto.message_field(
        3, optional=True, group="empty"
    )

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


rebuild_dataclass(Test)  # type: ignore
