Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
exceptions.py96 linesDownload Raw Back to attr
1# SPDX-License-Identifier: MIT2 3from __future__ import annotations4 5 6class FrozenError(AttributeError):7    """8    A frozen/immutable instance or attribute have been attempted to be9    modified.10 11    It mirrors the behavior of ``namedtuples`` by using the same error message12    and subclassing `AttributeError`.13 14    .. versionadded:: 20.1.015    """16 17    def __init__(self):18        msg = "can't set attribute"19        super().__init__(msg)20        self.msg = msg21 22 23class FrozenInstanceError(FrozenError):24    """25    A frozen instance has been attempted to be modified.26 27    .. versionadded:: 16.1.028    """29 30 31class FrozenAttributeError(FrozenError):32    """33    A frozen attribute has been attempted to be modified.34 35    .. versionadded:: 20.1.036    """37 38 39class AttrsAttributeNotFoundError(ValueError):40    """41    An *attrs* function couldn't find an attribute that the user asked for.42 43    .. versionadded:: 16.2.044    """45 46 47class NotAnAttrsClassError(ValueError):48    """49    A non-*attrs* class has been passed into an *attrs* function.50 51    .. versionadded:: 16.2.052    """53 54 55class DefaultAlreadySetError(RuntimeError):56    """57    A default has been set when defining the field and is attempted to be reset58    using the decorator.59 60    .. versionadded:: 17.1.061    """62 63 64class UnannotatedAttributeError(RuntimeError):65    """66    A class with ``auto_attribs=True`` has a field without a type annotation.67 68    .. versionadded:: 17.3.069    """70 71 72class PythonTooOldError(RuntimeError):73    """74    It was attempted to use an *attrs* feature that requires a newer Python75    version.76 77    .. versionadded:: 18.2.078    """79 80 81class NotCallableError(TypeError):82    """83    A field requiring a callable has been set with a value that is not84    callable.85 86    .. versionadded:: 19.2.087    """88 89    def __init__(self, msg, value):90        super(TypeError, self).__init__(msg, value)91        self.msg = msg92        self.value = value93 94    def __str__(self):95        return str(self.msg)96 
codekingpro/portable-devtools · Team Ai