10 examples of 'python ignore deprecationwarning' in Python

Every line of 'python ignore deprecationwarning' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
173def deprecated(msg, level=3):
174 # level is the stack level
175 # 1: the line below
176 # 2: the line calling this function
177 # 3: the line calling the function that
178 # called this function
179 if DEBUG:
180 warnings.warn(msg, DeprecationWarning, level)
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

22def deprecation(message, stacklevel=None):
23 """Warns about some type of deprecation that has been (or will be) made.
24
25 This helper function makes it easier to interact with the warnings module
26 by standardizing the arguments that the warning function recieves so that
27 it is easier to use.
28
29 This should be used to emit warnings to users (users can easily turn these
30 warnings off/on, see https://docs.python.org/2/library/warnings.html
31 as they see fit so that the messages do not fill up the users logs with
32 warnings that they do not wish to see in production) about functions,
33 methods, attributes or other code that is deprecated and will be removed
34 in a future release (this is done using these warnings to avoid breaking
35 existing users of those functions, methods, code; which a library should
36 avoid doing by always giving at *least* N + 1 release for users to address
37 the deprecation warnings).
38 """
39 if stacklevel is None:
40 warnings.warn(message, category=DeprecationWarning)
41 else:
42 warnings.warn(message,
43 category=DeprecationWarning, stacklevel=stacklevel)
20def _check_deprecated(name, deprecation_version):
21 if objc.options.deprecation_warnings and objc.options.deprecation_warnings >= deprecation_version:
22 warnings.warn("%r is deprecated in macOS %d.%d"%(name, deprecation_version / 100, deprecation_version % 100),
23 objc.ApiDeprecationWarning, stacklevel=2)
29def warn_deprecation(msg):
30 """
31 Raise a warning and prints a deprecation message to stdout.
32
33 Parameters
34 ----------
35 msg : str
36 Message that will be printed to stdout.
37 """
38 # Deprecation warnings need to be printed regardless of debug level
39 warnings.simplefilter('always', DeprecationWarning)
40
41 # note, stack level 3 should take us back to original caller.
42 simple_warning(msg, DeprecationWarning, stacklevel=3)
43 warnings.simplefilter('ignore', DeprecationWarning)
46def deprecated(name): # pragma: no cover
47 warnings.warn(WARNING.format(name), DeprecationWarning)
21def warn_deprecated(msg, stacklevel=3):
22 warnings.warn(msg, exc.SADeprecationWarning, stacklevel=stacklevel)
51def show_warning(obj: _FT):
52 warnings.simplefilter("always", DeprecationWarning)
53 warnings.warn(
54 get_message(obj), category=DeprecationWarning, stacklevel=2
55 )
56 warnings.simplefilter("default", DeprecationWarning)
13def __deprecated__(s):
14 warnings.warn(s, DeprecationWarning)
722def deprecation(message):
723 warnings.warn(message, DeprecationWarning, stacklevel=2)
40def _warning(self):
41 frame, __, lineno, funcname, __, __ = inspect.stack()[2]
42 module = inspect.getmodule(frame)
43 logger = logging.getLogger(module.__name__)
44 lineno = lineno
45 logger.warning('Deprecated: class %s must be replaced by %s '
46 'at line %r',
47 self.oldname,
48 self.replacement.__name__,
49 lineno)

Related snippets