SILENT KILLERPanel

Current Path: > > opt > alt > python37 > lib > python3.7 > site-packages > attr >


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: //opt/alt/python37/lib/python3.7/site-packages/attr/

NameTypeSizeLast ModifiedActions
__pycache__ Directory - -
__init__.py File 1613 bytes May 07 2021 09:20:15.
__init__.pyi File 14837 bytes May 05 2021 08:25:16.
_cmp.py File 4133 bytes May 06 2021 07:03:24.
_cmp.pyi File 318 bytes May 01 2021 12:26:39.
_compat.py File 7562 bytes February 27 2021 09:49:47.
_config.py File 514 bytes October 17 2019 08:29:00.
_funcs.py File 13398 bytes May 06 2021 14:11:04.
_make.py File 97743 bytes May 05 2021 08:05:42.
_next_gen.py File 4072 bytes April 12 2021 12:35:56.
_version_info.py File 2162 bytes March 29 2020 07:56:49.
_version_info.pyi File 209 bytes March 29 2020 07:56:49.
converters.py File 3039 bytes February 18 2021 15:38:25.
converters.pyi File 382 bytes February 19 2021 07:15:51.
exceptions.py File 1949 bytes April 30 2021 12:38:44.
exceptions.pyi File 540 bytes February 19 2021 07:15:51.
filters.py File 1098 bytes March 29 2020 07:56:49.
filters.pyi File 216 bytes February 19 2021 07:15:51.
py.typed File 0 bytes July 12 2018 10:28:53.
setters.py File 1434 bytes July 20 2020 10:43:42.
setters.pyi File 574 bytes April 06 2021 04:14:02.
validators.py File 11497 bytes July 20 2020 10:43:42.
validators.pyi File 1870 bytes February 19 2021 07:15:51.

Reading File: //opt/alt/python37/lib/python3.7/site-packages/attr//_next_gen.py

"""
These are Python 3.6+-only and keyword-only APIs that call `attr.s` and
`attr.ib` with different default values.
"""

from functools import partial

from attr.exceptions import UnannotatedAttributeError

from . import setters
from ._make import NOTHING, _frozen_setattrs, attrib, attrs


def define(
    maybe_cls=None,
    *,
    these=None,
    repr=None,
    hash=None,
    init=None,
    slots=True,
    frozen=False,
    weakref_slot=True,
    str=False,
    auto_attribs=None,
    kw_only=False,
    cache_hash=False,
    auto_exc=True,
    eq=None,
    order=False,
    auto_detect=True,
    getstate_setstate=None,
    on_setattr=None,
    field_transformer=None,
):
    r"""
    The only behavioral differences are the handling of the *auto_attribs*
    option:

    :param Optional[bool] auto_attribs: If set to `True` or `False`, it behaves
       exactly like `attr.s`. If left `None`, `attr.s` will try to guess:

       1. If any attributes are annotated and no unannotated `attr.ib`\ s
          are found, it assumes *auto_attribs=True*.
       2. Otherwise it assumes *auto_attribs=False* and tries to collect
          `attr.ib`\ s.

    and that mutable classes (``frozen=False``) validate on ``__setattr__``.

    .. versionadded:: 20.1.0
    """

    def do_it(cls, auto_attribs):
        return attrs(
            maybe_cls=cls,
            these=these,
            repr=repr,
            hash=hash,
            init=init,
            slots=slots,
            frozen=frozen,
            weakref_slot=weakref_slot,
            str=str,
            auto_attribs=auto_attribs,
            kw_only=kw_only,
            cache_hash=cache_hash,
            auto_exc=auto_exc,
            eq=eq,
            order=order,
            auto_detect=auto_detect,
            collect_by_mro=True,
            getstate_setstate=getstate_setstate,
            on_setattr=on_setattr,
            field_transformer=field_transformer,
        )

    def wrap(cls):
        """
        Making this a wrapper ensures this code runs during class creation.

        We also ensure that frozen-ness of classes is inherited.
        """
        nonlocal frozen, on_setattr

        had_on_setattr = on_setattr not in (None, setters.NO_OP)

        # By default, mutable classes validate on setattr.
        if frozen is False and on_setattr is None:
            on_setattr = setters.validate

        # However, if we subclass a frozen class, we inherit the immutability
        # and disable on_setattr.
        for base_cls in cls.__bases__:
            if base_cls.__setattr__ is _frozen_setattrs:
                if had_on_setattr:
                    raise ValueError(
                        "Frozen classes can't use on_setattr "
                        "(frozen-ness was inherited)."
                    )

                on_setattr = setters.NO_OP
                break

        if auto_attribs is not None:
            return do_it(cls, auto_attribs)

        try:
            return do_it(cls, True)
        except UnannotatedAttributeError:
            return do_it(cls, False)

    # maybe_cls's type depends on the usage of the decorator.  It's a class
    # if it's used as `@attrs` but ``None`` if used as `@attrs()`.
    if maybe_cls is None:
        return wrap
    else:
        return wrap(maybe_cls)


mutable = define
frozen = partial(define, frozen=True, on_setattr=None)


def field(
    *,
    default=NOTHING,
    validator=None,
    repr=True,
    hash=None,
    init=True,
    metadata=None,
    converter=None,
    factory=None,
    kw_only=False,
    eq=None,
    order=None,
    on_setattr=None,
):
    """
    Identical to `attr.ib`, except keyword-only and with some arguments
    removed.

    .. versionadded:: 20.1.0
    """
    return attrib(
        default=default,
        validator=validator,
        repr=repr,
        hash=hash,
        init=init,
        metadata=metadata,
        converter=converter,
        factory=factory,
        kw_only=kw_only,
        eq=eq,
        order=order,
        on_setattr=on_setattr,
    )

SILENT KILLER Tool