bw2data.backends.typos#

Attributes#

Functions#

_check_keys(→ None)

Checks keys of a dictionary obj against a set of valid keys. If a key

_check_type(→ None)

Validates the type_value against a set of valid types. If the `type_value

Module Contents#

bw2data.backends.typos._check_keys(obj: dict, kind: str, valid: Iterable[str]) None[source]#

Checks keys of a dictionary obj against a set of valid keys. If a key is a close match to any of the valid keys, a warning is raised indicating a possible incorrect key.

Parameters:
  • obj (dict) – The dictionary whose keys are to be checked.

  • kind (str) – The category of the keys being checked (e.g., ‘activity’, ‘exchange’).

  • valid (Iterable[str]) – An iterable of valid key values.

Raises:

UserWarning – Warns if a key in obj is not in valid but is close to a valid key.

Examples

>>> _check_keys({"actvty": "value"}, "activity", ["activity", "process"])
Possible incorrect activity key found: Given `actvty` but `activity` is more common
bw2data.backends.typos._check_type(type_value: str, kind: str, valid: Iterable[str]) None[source]#

Validates the type_value against a set of valid types. If the `type_value is a close match (based on Damerau-Levenshtein distance) to any of the valid types a warning is raised indicating a possible typo.

Parameters:
  • type_value (str) – The type value to be checked.

  • kind (str) – The category of the type being checked (e.g., ‘activity’, ‘exchange’).

  • valid (Iterable[str]) – An iterable of valid type values.

Raises:

UserWarning – Warns if type_value is not in valid but is close to a valid value.

Examples

>>> _check_type("actvty", "activity", ["activity", "process"])
Possible typo found: Given activity type `actvty` but `activity` is more common
bw2data.backends.typos.check_activity_keys[source]#
bw2data.backends.typos.check_activity_type[source]#
bw2data.backends.typos.check_exchange_keys[source]#
bw2data.backends.typos.check_exchange_type[source]#
bw2data.backends.typos.damerau_levenshtein[source]#