Server IP : 209.38.156.173 / Your IP : 216.73.216.122 [ Web Server : Apache/2.4.52 (Ubuntu) System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.1.2-1ubuntu2.22 Disable Function : NONE Domains : 2 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /lib/python3/dist-packages/zope/interface/common/__pycache__/ |
Upload File : |
o $ x`�( � @ s� d dl Z d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlm Z g Z G dd � d e�ZG d d� de�Z dd � Ze� ZdS )� N)�FunctionType)�classImplements)� Interface)�fromFunction)�InterfaceClass)�_decorator_non_returnc @ s e Zd Zdd� ZdS )�optionalc C s |j | _ d S �N��__doc__)�self�method� r �@/usr/lib/python3/dist-packages/zope/interface/common/__init__.py�__init__# s zoptional.__init__N)�__name__� __module__�__qualname__r r r r r r s r c @ sf e Zd ZdZdd� Zedd� �Zdd� Zedd � �Zed d� �Z dd � Z ddd�Zdd� Zdd� Z dS )�ABCInterfaceClassa� An interface that is automatically derived from a :class:`abc.ABCMeta` type. Internal use only. The body of the interface definition *must* define a property ``abc`` that is the ABC to base the interface on. If ``abc`` is *not* in the interface definition, a regular interface will be defined instead (but ``extra_classes`` is still respected). Use the ``@optional`` decorator on method definitions if the ABC defines methods that are not actually required in all cases because the Python language has multiple ways to implement a protocol. For example, the ``iter()`` protocol can be implemented with ``__iter__`` or the pair ``__len__`` and ``__getitem__``. When created, any existing classes that are registered to conform to the ABC are declared to implement this interface. This is *not* automatically updated as the ABC registry changes. If the body of the interface definition defines ``extra_classes``, it should be a tuple giving additional classes to declare implement the interface. Note that this is not fully symmetric. For example, it is usually the case that a subclass relationship carries the interface declarations over:: >>> from zope.interface import Interface >>> class I1(Interface): ... pass ... >>> from zope.interface import implementer >>> @implementer(I1) ... class Root(object): ... pass ... >>> class Child(Root): ... pass ... >>> child = Child() >>> isinstance(child, Root) True >>> from zope.interface import providedBy >>> list(providedBy(child)) [<InterfaceClass __main__.I1>] However, that's not the case with ABCs and ABC interfaces. Just because ``isinstance(A(), AnABC)`` and ``isinstance(B(), AnABC)`` are both true, that doesn't mean there's any class hierarchy relationship between ``A`` and ``B``, or between either of them and ``AnABC``. Thus, if ``AnABC`` implemented ``IAnABC``, it would not follow that either ``A`` or ``B`` implements ``IAnABC`` (nor their instances provide it):: >>> class SizedClass(object): ... def __len__(self): return 1 ... >>> from collections.abc import Sized >>> isinstance(SizedClass(), Sized) True >>> from zope.interface import classImplements >>> classImplements(Sized, I1) None >>> list(providedBy(SizedClass())) [] Thus, to avoid conflicting assumptions, ABCs should not be declared to implement their parallel ABC interface. Only concrete classes specifically registered with the ABC should be declared to do so. .. versionadded:: 5.0.0 c s� |� _ |�dd�}|�dd�}d|vr't�� |||� t�� ||� t� _d S |�d�}|� _t|�� _ t|�� _ |dd � |j ksHJ ||f��� fdd�t|��� D �}� � |�|d<