• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zopefoundation / zope.proxy / 16098813542

18 Feb 2025 08:01AM UTC coverage: 99.941% (+0.002%) from 99.939%
16098813542

push

github

web-flow
Update Python version support. (#74)

* Drop support for Python 3.8.
* Add preliminary support for Python 3.14.

---------

Co-authored-by: Jens Vagelpohl <jens@plyp.com>

213 of 213 branches covered (100.0%)

Branch coverage included in aggregate %.

1481 of 1482 relevant lines covered (99.93%)

6.99 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/zope/proxy/decorator.py
1
##############################################################################
2
#
3
# Copyright (c) 2003 Zope Foundation and Contributors.
4
# All Rights Reserved.
5
#
6
# This software is subject to the provisions of the Zope Public License,
7
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
8
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
9
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
11
# FOR A PARTICULAR PURPOSE.
12
#
13
##############################################################################
14
"""Decorator support
7✔
15

16
Decorators are proxies that are mostly transparent but that may provide
17
additional features.
18
"""
19
__docformat__ = "reStructuredText"
7✔
20

21
from zope.interface import providedBy
7✔
22
from zope.interface.declarations import ObjectSpecification
7✔
23
from zope.interface.declarations import ObjectSpecificationDescriptor
7✔
24
from zope.interface.declarations import getObjectSpecification
7✔
25

26
from zope.proxy import ProxyBase
7✔
27
from zope.proxy import getProxiedObject
7✔
28

29

30
class DecoratorSpecificationDescriptor(ObjectSpecificationDescriptor):
7✔
31
    """Support for interface declarations on decorators
32
    """
33

34
    def __get__(self, inst, cls=None):
7✔
35
        if inst is None:
7✔
36
            return getObjectSpecification(cls)
7✔
37
        else:
38
            provided = providedBy(getProxiedObject(inst))
7✔
39

40
            # Use type rather than __class__ because inst is a proxy and
41
            # will return the proxied object's class.
42
            cls = type(inst)
7✔
43
            return ObjectSpecification(provided, cls)
7✔
44

45
    def __set__(self, inst, value):
7✔
46
        raise TypeError("Can't set __providedBy__ on a decorated object")
7✔
47

48

49
class SpecificationDecoratorBase(ProxyBase):
7✔
50
    """Base class for a proxy that provides additional interfaces."""
51

52
    __providedBy__ = DecoratorSpecificationDescriptor()
7✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc