#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import dataclasses
from typing import Type

from .typed import (
    __setattr_coerced__,
    _get_setter,
    typed_callable,
    annotations,
    _TO_RESOLVE,
)


def make_typedclass(
    cls: Type,
    *,
    init: bool = True,
    repr: bool = True,
    eq: bool = True,
    order: bool = False,
    unsafe_hash: bool = False,
    frozen: bool = False,
    delay: bool = False
):
    # Make the base dataclass.
    dcls = dataclasses.dataclass(
        cls,
        init=init,
        repr=repr,
        eq=eq,
        order=order,
        unsafe_hash=unsafe_hash,
        frozen=frozen,
    )
    ddict = dict(dcls.__dict__)
    ddict.pop("__dict__", None)
    ddict.pop("__weakref__", None)
    bases = (dcls,) + dcls.__bases__
    tcls = type(dcls.__name__, bases, ddict)
    tcls.__qualname__ = cls.__qualname__
    # Resolve the annotations.
    if not delay:
        annotations(tcls)
    else:
        _TO_RESOLVE.append(tcls)
    # Frozen dataclasses don't use the native setattr
    # So we wrap the init. This should be fine, but is more expensive.
    if frozen:
        tcls.__init__ = typed_callable(tcls.__init__)
    else:
        tcls.__setattr_original__ = _get_setter(tcls, bases)
        tcls.__setattr__ = __setattr_coerced__
    return tcls


def klass(
    _cls: Type = None,
    *,
    init: bool = True,
    repr: bool = True,
    eq: bool = True,
    order: bool = False,
    unsafe_hash: bool = False,
    frozen: bool = False,
    delay: bool = False
):
    def typedclass_wrapper(cls_):
        return make_typedclass(
            cls=cls_,
            init=init,
            repr=repr,
            eq=eq,
            order=order,
            unsafe_hash=unsafe_hash,
            frozen=frozen,
            delay=delay,
        )

    return typedclass_wrapper(_cls) if _cls else typedclass_wrapper

ca31a801aa9ed50486ad87911fc3353a92c6e74d
<mask token>

<mask token>


def make_typedclass(cls: Type, *, init: bool=True, repr: bool=True, eq:
    bool=True, order: bool=False, unsafe_hash: bool=False, frozen: bool=
    False, delay: bool=False):
    dcls = dataclasses.dataclass(cls, init=init, repr=repr, eq=eq, order=
        order, unsafe_hash=unsafe_hash, frozen=frozen)
    ddict = dict(dcls.__dict__)
    ddict.pop('__dict__', None)
    ddict.pop('__weakref__', None)
    bases = (dcls,) + dcls.__bases__
    tcls = type(dcls.__name__, bases, ddict)
    tcls.__qualname__ = cls.__qualname__
    if not delay:
        annotations(tcls)
    else:
        _TO_RESOLVE.append(tcls)
    if frozen:
        tcls.__init__ = typed_callable(tcls.__init__)
    else:
        tcls.__setattr_original__ = _get_setter(tcls, bases)
        tcls.__setattr__ = __setattr_coerced__
    return tcls


<mask token>

<mask token>


def make_typedclass(cls: Type, *, init: bool=True, repr: bool=True, eq:
    bool=True, order: bool=False, unsafe_hash: bool=False, frozen: bool=
    False, delay: bool=False):
    dcls = dataclasses.dataclass(cls, init=init, repr=repr, eq=eq, order=
        order, unsafe_hash=unsafe_hash, frozen=frozen)
    ddict = dict(dcls.__dict__)
    ddict.pop('__dict__', None)
    ddict.pop('__weakref__', None)
    bases = (dcls,) + dcls.__bases__
    tcls = type(dcls.__name__, bases, ddict)
    tcls.__qualname__ = cls.__qualname__
    if not delay:
        annotations(tcls)
    else:
        _TO_RESOLVE.append(tcls)
    if frozen:
        tcls.__init__ = typed_callable(tcls.__init__)
    else:
        tcls.__setattr_original__ = _get_setter(tcls, bases)
        tcls.__setattr__ = __setattr_coerced__
    return tcls


def klass(_cls: Type=None, *, init: bool=True, repr: bool=True, eq: bool=
    True, order: bool=False, unsafe_hash: bool=False, frozen: bool=False,
    delay: bool=False):

    def typedclass_wrapper(cls_):
        return make_typedclass(cls=cls_, init=init, repr=repr, eq=eq, order
            =order, unsafe_hash=unsafe_hash, frozen=frozen, delay=delay)
    return typedclass_wrapper(_cls) if _cls else typedclass_wrapper

import dataclasses
from typing import Type
from .typed import __setattr_coerced__, _get_setter, typed_callable, annotations, _TO_RESOLVE


def make_typedclass(cls: Type, *, init: bool=True, repr: bool=True, eq:
    bool=True, order: bool=False, unsafe_hash: bool=False, frozen: bool=
    False, delay: bool=False):
    dcls = dataclasses.dataclass(cls, init=init, repr=repr, eq=eq, order=
        order, unsafe_hash=unsafe_hash, frozen=frozen)
    ddict = dict(dcls.__dict__)
    ddict.pop('__dict__', None)
    ddict.pop('__weakref__', None)
    bases = (dcls,) + dcls.__bases__
    tcls = type(dcls.__name__, bases, ddict)
    tcls.__qualname__ = cls.__qualname__
    if not delay:
        annotations(tcls)
    else:
        _TO_RESOLVE.append(tcls)
    if frozen:
        tcls.__init__ = typed_callable(tcls.__init__)
    else:
        tcls.__setattr_original__ = _get_setter(tcls, bases)
        tcls.__setattr__ = __setattr_coerced__
    return tcls


def klass(_cls: Type=None, *, init: bool=True, repr: bool=True, eq: bool=
    True, order: bool=False, unsafe_hash: bool=False, frozen: bool=False,
    delay: bool=False):

    def typedclass_wrapper(cls_):
        return make_typedclass(cls=cls_, init=init, repr=repr, eq=eq, order
            =order, unsafe_hash=unsafe_hash, frozen=frozen, delay=delay)
    return typedclass_wrapper(_cls) if _cls else typedclass_wrapper

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import dataclasses
from typing import Type

from .typed import (
    __setattr_coerced__,
    _get_setter,
    typed_callable,
    annotations,
    _TO_RESOLVE,
)


def make_typedclass(
    cls: Type,
    *,
    init: bool = True,
    repr: bool = True,
    eq: bool = True,
    order: bool = False,
    unsafe_hash: bool = False,
    frozen: bool = False,
    delay: bool = False
):
    # Make the base dataclass.
    dcls = dataclasses.dataclass(
        cls,
        init=init,
        repr=repr,
        eq=eq,
        order=order,
        unsafe_hash=unsafe_hash,
        frozen=frozen,
    )
    ddict = dict(dcls.__dict__)
    ddict.pop("__dict__", None)
    ddict.pop("__weakref__", None)
    bases = (dcls,) + dcls.__bases__
    tcls = type(dcls.__name__, bases, ddict)
    tcls.__qualname__ = cls.__qualname__
    # Resolve the annotations.
    if not delay:
        annotations(tcls)
    else:
        _TO_RESOLVE.append(tcls)
    # Frozen dataclasses don't use the native setattr
    # So we wrap the init. This should be fine, but is more expensive.
    if frozen:
        tcls.__init__ = typed_callable(tcls.__init__)
    else:
        tcls.__setattr_original__ = _get_setter(tcls, bases)
        tcls.__setattr__ = __setattr_coerced__
    return tcls


def klass(
    _cls: Type = None,
    *,
    init: bool = True,
    repr: bool = True,
    eq: bool = True,
    order: bool = False,
    unsafe_hash: bool = False,
    frozen: bool = False,
    delay: bool = False
):
    def typedclass_wrapper(cls_):
        return make_typedclass(
            cls=cls_,
            init=init,
            repr=repr,
            eq=eq,
            order=order,
            unsafe_hash=unsafe_hash,
            frozen=frozen,
            delay=delay,
        )

    return typedclass_wrapper(_cls) if _cls else typedclass_wrapper
