summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/util/deprecations.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-01-06 01:14:26 -0500
committermike bayer <mike_mp@zzzcomputing.com>2019-01-06 17:34:50 +0000
commit1e1a38e7801f410f244e4bbb44ec795ae152e04e (patch)
tree28e725c5c8188bd0cfd133d1e268dbca9b524978 /lib/sqlalchemy/util/deprecations.py
parent404e69426b05a82d905cbb3ad33adafccddb00dd (diff)
downloadsqlalchemy-1e1a38e7801f410f244e4bbb44ec795ae152e04e.tar.gz
Run black -l 79 against all source files
This is a straight reformat run using black as is, with no edits applied at all. The black run will format code consistently, however in some cases that are prevalent in SQLAlchemy code it produces too-long lines. The too-long lines will be resolved in the following commit that will resolve all remaining flake8 issues including shadowed builtins, long lines, import order, unused imports, duplicate imports, and docstring issues. Change-Id: I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9
Diffstat (limited to 'lib/sqlalchemy/util/deprecations.py')
-rw-r--r--lib/sqlalchemy/util/deprecations.py35
1 files changed, 22 insertions, 13 deletions
diff --git a/lib/sqlalchemy/util/deprecations.py b/lib/sqlalchemy/util/deprecations.py
index 9000cc795..e6612f075 100644
--- a/lib/sqlalchemy/util/deprecations.py
+++ b/lib/sqlalchemy/util/deprecations.py
@@ -40,8 +40,7 @@ def deprecated(version, message=None, add_deprecation_to_docstring=True):
"""
if add_deprecation_to_docstring:
- header = ".. deprecated:: %s %s" % \
- (version, (message or ''))
+ header = ".. deprecated:: %s %s" % (version, (message or ""))
else:
header = None
@@ -50,13 +49,18 @@ def deprecated(version, message=None, add_deprecation_to_docstring=True):
def decorate(fn):
return _decorate_with_warning(
- fn, exc.SADeprecationWarning,
- message % dict(func=fn.__name__), header)
+ fn,
+ exc.SADeprecationWarning,
+ message % dict(func=fn.__name__),
+ header,
+ )
+
return decorate
-def pending_deprecation(version, message=None,
- add_deprecation_to_docstring=True):
+def pending_deprecation(
+ version, message=None, add_deprecation_to_docstring=True
+):
"""Decorates a function and issues a pending deprecation warning on use.
:param version:
@@ -74,8 +78,7 @@ def pending_deprecation(version, message=None,
"""
if add_deprecation_to_docstring:
- header = ".. deprecated:: %s (pending) %s" % \
- (version, (message or ''))
+ header = ".. deprecated:: %s (pending) %s" % (version, (message or ""))
else:
header = None
@@ -84,8 +87,12 @@ def pending_deprecation(version, message=None,
def decorate(fn):
return _decorate_with_warning(
- fn, exc.SAPendingDeprecationWarning,
- message % dict(func=fn.__name__), header)
+ fn,
+ exc.SAPendingDeprecationWarning,
+ message % dict(func=fn.__name__),
+ header,
+ )
+
return decorate
@@ -95,7 +102,8 @@ def _sanitize_restructured_text(text):
if type_ in ("func", "meth"):
name += "()"
return name
- return re.sub(r'\:(\w+)\:`~?\.?(.+?)`', repl, text)
+
+ return re.sub(r"\:(\w+)\:`~?\.?(.+?)`", repl, text)
def _decorate_with_warning(func, wtype, message, docstring_header=None):
@@ -108,7 +116,7 @@ def _decorate_with_warning(func, wtype, message, docstring_header=None):
warnings.warn(message, wtype, stacklevel=3)
return fn(*args, **kwargs)
- doc = func.__doc__ is not None and func.__doc__ or ''
+ doc = func.__doc__ is not None and func.__doc__ or ""
if docstring_header is not None:
docstring_header %= dict(func=func.__name__)
@@ -118,6 +126,7 @@ def _decorate_with_warning(func, wtype, message, docstring_header=None):
decorated.__doc__ = doc
return decorated
+
import textwrap
@@ -135,7 +144,7 @@ def _dedent_docstring(text):
def inject_docstring_text(doctext, injecttext, pos):
doctext = _dedent_docstring(doctext or "")
- lines = doctext.split('\n')
+ lines = doctext.split("\n")
injectlines = textwrap.dedent(injecttext).split("\n")
if injectlines[0]:
injectlines.insert(0, "")