def rename_kwargs(func_name, kwargs, aliases): for alias, new in aliases.items(): if alias in kwargs: if new in kwargs: raise InvalidParamException( '{} received both {} and {}'.format(func_name, alias, new)) # Manually invoke the deprecated decorator with an empty lambda # to signal deprecation deprecated(deprecated_in='1.1', removed_in='2.0', current_version=cloudbridge.__version__, details='{} is deprecated, use {} instead'.format( alias, new))(lambda: None)() kwargs[new] = kwargs.pop(alias)
def deprecated_since_06(func): import deprecation return deprecation.deprecated( deprecated_in=0.6, removed_in=0.8, details="This function is part of the legacy templating system.")(func)
def deprecate(func): return deprecation.deprecated( deprecated_in='0.24.0', removed_in='1.0.0', details='Use the fsleyes.layout module')(func)
with ElasticSearchContainer() as es: connection_url = es.get_url() """ def __init__(self, image="elasticsearch:7.5.0", port_to_expose=9200): super(ElasticSearchContainer, self).__init__(image) self.port_to_expose = port_to_expose self.with_exposed_ports(self.port_to_expose) self.with_env('transport.host', '127.0.0.1') self.with_env('http.host', '0.0.0.0') self.with_env('discovery.zen.minimum_master_nodes', '1') @wait_container_is_ready() def _connect(self): res = urllib.request.urlopen(self.get_url()) if res.status != 200: raise Exception() def get_url(self): host = self.get_container_host_ip() port = self.get_exposed_port(self.port_to_expose) return 'http://{}:{}'.format(host, port) def start(self): super().start() self._connect() return self ElasticsearchContainer = deprecated(details='Use `ElasticSearchContainer` with a capital S instead ' 'of `ElasticsearchContainer`.')(ElasticSearchContainer)
def deprecatedemo4(): """Demonstrate that deprecate() also works in a local scope.""" deprecated('demo4', 'demo4 is no more.')
import doctest from zope.testing import renormalizing import os import re import shutil import sys import tempfile import unittest import warnings import zope.deprecation # Used in doctests from deprecation import deprecated demo1 = 1 deprecated('demo1', 'demo1 is no more.') demo2 = 2 deprecated('demo2', 'demo2 is no more.') demo3 = 3 deprecated('demo3', 'demo3 is no more.') demo4 = 4 def deprecatedemo4(): """Demonstrate that deprecate() also works in a local scope.""" deprecated('demo4', 'demo4 is no more.')
from zope.testing import doctest from zope.testing import renormalizing import os import re import shutil import sys import tempfile import unittest import warnings import zope.deprecation # Used in doctests from deprecation import deprecated demo1 = 1 deprecated('demo1', 'demo1 is no more.') demo2 = 2 deprecated('demo2', 'demo2 is no more.') demo3 = 3 deprecated('demo3', 'demo3 is no more.') demo4 = 4 def deprecatedemo4(): """Demonstrate that deprecate() also works in a local scope.""" deprecated('demo4', 'demo4 is no more.') def warn(message, type_, stacklevel): print "From tests.py's showwarning():"
def deprecated(deprecated_in: str = None, removed_in: str = None, details=""): return deprecation.deprecated(deprecated_in=deprecated_in, removed_in=removed_in, current_version=version.version, details=details)