MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / deprecated

Function deprecated

lib/sqlalchemy/util/deprecations.py:99–150  ·  view source on GitHub ↗

Decorates a function and issues a deprecation warning on use. :param version: Issue version in the warning. :param message: If provided, issue message in the warning. A sensible default is used if not provided. :param add_deprecation_to_docstring: Default True

(
    version: str,
    message: Optional[str] = None,
    add_deprecation_to_docstring: bool = True,
    warning: Optional[Type[exc.SADeprecationWarning]] = None,
    enable_warnings: bool = True,
)

Source from the content-addressed store, hash-verified

97
98
99def deprecated(
100 version: str,
101 message: Optional[str] = None,
102 add_deprecation_to_docstring: bool = True,
103 warning: Optional[Type[exc.SADeprecationWarning]] = None,
104 enable_warnings: bool = True,
105) -> Callable[[_F], _F]:
106 """Decorates a function and issues a deprecation warning on use.
107
108 :param version:
109 Issue version in the warning.
110
111 :param message:
112 If provided, issue message in the warning. A sensible default
113 is used if not provided.
114
115 :param add_deprecation_to_docstring:
116 Default True. If False, the wrapped function's __doc__ is left
117 as-is. If True, the 'message' is prepended to the docs if
118 provided, or sensible default if message is omitted.
119
120 """
121
122 if add_deprecation_to_docstring:
123 header = ".. deprecated:: %s %s" % (
124 version,
125 (message or ""),
126 )
127 else:
128 header = None
129
130 if message is None:
131 message = "Call to deprecated function %(func)s"
132
133 if warning is None:
134 warning = exc.SADeprecationWarning
135
136 message += " (deprecated since: %s)" % version
137
138 def decorate(fn: _F) -> _F:
139 assert message is not None
140 assert warning is not None
141 return _decorate_with_warning(
142 fn,
143 warning,
144 message % dict(func=fn.__name__),
145 version,
146 header,
147 enable_warnings=enable_warnings,
148 )
149
150 return decorate
151
152
153def moved_20(

Callers 2

moved_20Function · 0.85
became_legacy_20Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected