diff options
Diffstat (limited to 'contrib/python/zope.interface/py3/zope/interface/exceptions.py')
-rw-r--r-- | contrib/python/zope.interface/py3/zope/interface/exceptions.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/contrib/python/zope.interface/py3/zope/interface/exceptions.py b/contrib/python/zope.interface/py3/zope/interface/exceptions.py index 0612eb230e..b86fb1e04c 100644 --- a/contrib/python/zope.interface/py3/zope/interface/exceptions.py +++ b/contrib/python/zope.interface/py3/zope/interface/exceptions.py @@ -26,6 +26,7 @@ __all__ = [ 'InvalidInterface', ] + class Invalid(Exception): """A specification is violated """ @@ -55,7 +56,7 @@ class _TargetInvalid(Invalid): def _get_arg_or_default(self, ix, default=None): try: - return self.args[ix] # pylint:disable=unsubscriptable-object + return self.args[ix] # pylint:disable=unsubscriptable-object except self._NOT_GIVEN_CATCH: return default @@ -92,7 +93,7 @@ class _TargetInvalid(Invalid): target = self.target if target is self._NOT_GIVEN: return "An object" - return "The object {!r}".format(target) + return f"The object {target!r}" @property def _str_description(self): @@ -146,7 +147,7 @@ class BrokenImplementation(_TargetInvalid): @property def name(self): - return self.args[1] # pylint:disable=unsubscriptable-object + return self.args[1] # pylint:disable=unsubscriptable-object @property def _str_details(self): @@ -157,7 +158,9 @@ class BrokenImplementation(_TargetInvalid): class BrokenMethodImplementation(_TargetInvalid): """ - BrokenMethodImplementation(method, message[, implementation, interface, target]) + BrokenMethodImplementation( + method, message[, implementation, interface, target] + ) The *target* (optional) has a *method* in *implementation* that violates its contract in a way described by *mess*. @@ -181,11 +184,11 @@ class BrokenMethodImplementation(_TargetInvalid): @property def method(self): - return self.args[0] # pylint:disable=unsubscriptable-object + return self.args[0] # pylint:disable=unsubscriptable-object @property def mess(self): - return self.args[1] # pylint:disable=unsubscriptable-object + return self.args[1] # pylint:disable=unsubscriptable-object @staticmethod def __implementation_str(impl): @@ -197,8 +200,7 @@ class BrokenMethodImplementation(_TargetInvalid): formatsig = str except AttributeError: sig = inspect.getargspec - f = inspect.formatargspec - formatsig = lambda sig: f(*sig) # pylint:disable=deprecated-method + formatsig = inspect.formatargspec try: sig = sig(impl) @@ -248,7 +250,7 @@ class MultipleInvalid(_TargetInvalid): @property def exceptions(self): - return self.args[2] # pylint:disable=unsubscriptable-object + return self.args[2] # pylint:disable=unsubscriptable-object @property def _str_details(self): @@ -259,7 +261,7 @@ class MultipleInvalid(_TargetInvalid): for x in self.exceptions ) - _str_conjunction = ':' # We don't want a trailing space, messes up doctests + _str_conjunction = ':' # no trailing space, messes up doctests _str_trailer = '' @@ -267,6 +269,7 @@ class InvalidInterface(Exception): """The interface has invalid contents """ + class BadImplements(TypeError): """An implementation assertion is invalid |