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: dict

A dict that 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#

*argsAny

Forwarded to dict to populate the initial contents.

deprecationsMapping

Maps each deprecated key to the reason shown in its warning. An empty mapping warns that a plain dict should be used instead.

versionstr, optional

Version in which the keys were deprecated, added to the message.

categorytype [ Warning ], optional

Default warning category for deprecated keys.

deprecated_categoriesMapping

Per-key overrides of category.

stacklevelint, optional

stacklevel for warnings.warn, so the warning points at the caller rather than at DeprecatedDict internals.

**kwargsAny

Forwarded to dict to 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.