MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / became_legacy_20

Function became_legacy_20

lib/sqlalchemy/util/deprecations.py:161–196  ·  view source on GitHub ↗
(
    api_name: str, alternative: Optional[str] = None, **kw: Any
)

Source from the content-addressed store, hash-verified

159
160
161def became_legacy_20(
162 api_name: str, alternative: Optional[str] = None, **kw: Any
163) -> Callable[[_F], _F]:
164 type_reg = re.match("^:(attr|func|meth):", api_name)
165 if type_reg:
166 type_ = {"attr": "attribute", "func": "function", "meth": "method"}[
167 type_reg.group(1)
168 ]
169 else:
170 type_ = "construct"
171 message = (
172 "The %s %s is considered legacy as of the "
173 "1.x series of SQLAlchemy and %s in 2.0."
174 % (
175 api_name,
176 type_,
177 "becomes a legacy construct",
178 )
179 )
180
181 if ":attr:" in api_name:
182 attribute_ok = kw.pop("warn_on_attribute_access", False)
183 if not attribute_ok:
184 assert kw.get("enable_warnings") is False, (
185 "attribute %s will emit a warning on read access. "
186 "If you *really* want this, "
187 "add warn_on_attribute_access=True. Otherwise please add "
188 "enable_warnings=False." % api_name
189 )
190
191 if alternative:
192 message += " " + alternative
193
194 warning_cls = exc.LegacyAPIWarning
195
196 return deprecated("2.0", message=message, warning=warning_cls, **kw)
197
198
199def deprecated_params(**specs: Tuple[str, str]) -> Callable[[_F], _F]:

Callers

nothing calls this directly

Calls 4

deprecatedFunction · 0.85
matchMethod · 0.45
popMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected