DeprecatedDict#
- class lsst.utils.DeprecatedDict(*args: ~typing.Any, deprecations: ~collections.abc.Mapping[~typing.Any, str], version: str = '', category: type[Warning] = <class 'FutureWarning'>, deprecated_categories: ~collections.abc.Mapping[~typing.Any, type[Warning]] | None = None, stacklevel: int = 2, **kwargs: ~typing.Any)#
Bases:
dictA
dictthat warns when deprecated keys are first used.DeprecatedDict behaves exactly like a built-in dict, except that each deprecated key carries a reason. The first time a deprecated key is used through a single-key operation (d[key], ~dict.get, ~dict.pop, ~dict.setdefault, d[key] = value and del d[key]), it warns with that reason. Bulk operations (iteration, copy,
dict(d),update) never warn.Parameters#
- *args
Any Forwarded to
dictto populate the initial contents.- deprecations
Mapping Maps each deprecated key to the reason shown in its warning. An empty mapping warns that a plain
dictshould be used instead.- version
str, optional Version in which the keys were deprecated, added to the message.
- category
type[Warning], optional Default warning category for deprecated keys.
- deprecated_categories
Mapping Per-key overrides of
category.- stacklevel
int, optional stacklevelforwarnings.warn, so the warning points at the caller rather than atDeprecatedDictinternals.- **kwargs
Any Forwarded to
dictto populate the initial contents.
Methods Summary
get(key[, default])Return the value for key if key is in the dictionary, else default.
pop(k[,d])If the key is not found, return the default if given; otherwise, raise a KeyError.
setdefault(key[, default])Insert key with a value of default if key is not in the dictionary.
Methods Documentation
- get(key: Any, default: Any = None) Any#
Return the value for key if key is in the dictionary, else default.
- pop(k[, d]) v, remove specified key and return the corresponding value.#
If the key is not found, return the default if given; otherwise, raise a KeyError.
- setdefault(key: Any, default: Any = None) Any#
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- *args