1"""Auxiliary definitions used in type annotations. 2""" 3 4# Copyright The Mbed TLS Contributors 5# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 6# 7 8from typing import Any 9 10# The typing_extensions module is necessary for type annotations that are 11# checked with mypy. It is only used for type annotations or to define 12# things that are themselves only used for type annotations. It is not 13# available on a default Python installation. Therefore, try loading 14# what we need from it for the sake of mypy (which depends on, or comes 15# with, typing_extensions), and if not define substitutes that lack the 16# static type information but are good enough at runtime. 17try: 18 from typing_extensions import Protocol #pylint: disable=import-error 19except ImportError: 20 class Protocol: #type: ignore 21 #pylint: disable=too-few-public-methods 22 pass 23 24class Writable(Protocol): 25 """Abstract class for typing hints.""" 26 # pylint: disable=no-self-use,too-few-public-methods,unused-argument 27 def write(self, text: str) -> Any: 28 ... 29