Renamed names#

Renamed public names (DESIGN D17).

Every rename of a public name is one Rename in RENAMES. While its alias is active, the old name still works and warns with PyTESDeprecationWarning; once the alias is retired, the old name raises an error that gives the new one. The entry is never deleted, so that the error keeps pointing to the new name.

The kinds of names covered:

  • "object": a class or function, by its full dotted path. The module that held the old name sets __getattr__ = module_getattr(__name__).

  • "option": the name of a model option, checked by pytes.BaseModel.process_options().

Variable and parameter names are not covered yet (DESIGN §3): PyBaMM looks them up itself.

To silence the warnings, filter PyTESDeprecationWarning; to find old names in your own code, turn it into an error (python -W error::DeprecationWarning).

exception pytes.deprecation.PyTESDeprecationWarning[source]#

Bases: DeprecationWarning

A PyTES name was renamed; the old name still works, but will stop working

class pytes.deprecation.Rename(kind: str, old: str, new: str, finding: str, renamed_in: str, removed_in: str, alias: bool = True)[source]#

Bases: object

A renamed public name.

Parameters:
  • kind (str) – "object" or "option" (see pytes.deprecation).

  • old (str) – The old name; for an object, its full dotted path.

  • new (str) – The new name; for an object, its full dotted path.

  • finding (str) – The entry in docs/design/findings.md that logs the rename, e.g. "F-050".

  • renamed_in (str) – The release that renamed it.

  • removed_in (str) – The release from which the old name no longer works. Equal to renamed_in for a rename without an alias.

  • alias (bool, optional) – Whether the old name still works, with a warning (default). Set to False when a release reaches removed_in; the tests fail until then.

property message#

What happened to the old name and what to use instead

pytes.deprecation.RENAMES = (Rename(kind='option', old='storage', new='storage along flow path', finding='F-050', renamed_in='0.1.0a3', removed_in='0.1.0a3', alias=False), Rename(kind='object', old='pytes.experiments.step.ConstantInputs', new='pytes.experiments.step.Inlet', finding='F-054', renamed_in='0.1.0a3', removed_in='0.2.0', alias=True), Rename(kind='object', old='pytes.experiments.step.ConstantPower', new='pytes.experiments.step.Power', finding='F-054', renamed_in='0.1.0a3', removed_in='0.2.0', alias=True), Rename(kind='object', old='pytes.submodels.LedgerWallCoupling', new='pytes.submodels.WallCoupling', finding='F-054', renamed_in='0.1.0a3', removed_in='0.2.0', alias=True), Rename(kind='object', old='pytes.submodels.coupling.LedgerWallCoupling', new='pytes.submodels.coupling.WallCoupling', finding='F-054', renamed_in='0.1.0a3', removed_in='0.2.0', alias=True), Rename(kind='object', old='pytes.submodels.FinPCMCoupling', new='pytes.submodels.FinStorageCoupling', finding='F-054', renamed_in='0.1.0a3', removed_in='0.2.0', alias=True), Rename(kind='object', old='pytes.submodels.coupling.FinPCMCoupling', new='pytes.submodels.coupling.FinStorageCoupling', finding='F-054', renamed_in='0.1.0a3', removed_in='0.2.0', alias=True))#

Every renamed public name, oldest first

pytes.deprecation.find(kind, old)[source]#

The Rename of an old name of the given kind, or None

pytes.deprecation.check(rename, error)[source]#

Warn that the old name is deprecated, or raise if its alias is retired.

Parameters:
  • rename (Rename)

  • error (type) – The exception to raise if the alias is retired.

Raises:

error – If the alias is retired.

pytes.deprecation.module_getattr(module)[source]#

A module-level __getattr__ that resolves the module’s renamed objects.

Parameters:

module (str) – The module’s __name__.