|
1 | 1 | from __future__ import annotations
|
2 | 2 |
|
3 | 3 | import pathlib
|
| 4 | +import warnings |
4 | 5 | from collections import OrderedDict
|
5 | 6 | from collections.abc import Iterable, MutableMapping, Sequence
|
6 | 7 | from typing import Any, TypedDict
|
@@ -153,3 +154,31 @@ def get_tag_regexes(
|
153 | 154 | **{f"${k}": v for k, v in regexs.items()},
|
154 | 155 | **{f"${{{k}}}": v for k, v in regexs.items()},
|
155 | 156 | }
|
| 157 | + |
| 158 | + |
| 159 | +def __getattr__(name: str) -> Any: |
| 160 | + # PEP-562: deprecate module-level variable |
| 161 | + |
| 162 | + # {"deprecated key": (value, "new key")} |
| 163 | + deprecated_vars = { |
| 164 | + "bump_pattern": (BUMP_PATTERN, "BUMP_PATTERN"), |
| 165 | + "bump_map": (BUMP_MAP, "BUMP_MAP"), |
| 166 | + "bump_map_major_version_zero": ( |
| 167 | + BUMP_MAP_MAJOR_VERSION_ZERO, |
| 168 | + "BUMP_MAP_MAJOR_VERSION_ZERO", |
| 169 | + ), |
| 170 | + "bump_message": (BUMP_MESSAGE, "BUMP_MESSAGE"), |
| 171 | + "change_type_order": (CHANGE_TYPE_ORDER, "CHANGE_TYPE_ORDER"), |
| 172 | + "encoding": (ENCODING, "ENCODING"), |
| 173 | + "name": (DEFAULT_SETTINGS["name"], "DEFAULT_SETTINGS['name']"), |
| 174 | + } |
| 175 | + if name not in deprecated_vars: |
| 176 | + value, replacement = deprecated_vars[name] |
| 177 | + warnings.warn( |
| 178 | + f"{name} is deprecated and will be removed in a future version. " |
| 179 | + f"Use {replacement} instead.", |
| 180 | + DeprecationWarning, |
| 181 | + stacklevel=2, |
| 182 | + ) |
| 183 | + return value |
| 184 | + raise AttributeError(f"{name} is not an attribute of {__name__}") |
0 commit comments