From ff6489cac718c4ba66ad06e673a905026892ce18 Mon Sep 17 00:00:00 2001 From: benpankow Date: Fri, 24 May 2024 10:51:35 -0700 Subject: [PATCH] update docstr --- .../_core/definitions/metadata/metadata_set.py | 16 ++++++++-------- .../dagster/_core/definitions/tags/tag_set.py | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/python_modules/dagster/dagster/_core/definitions/metadata/metadata_set.py b/python_modules/dagster/dagster/_core/definitions/metadata/metadata_set.py index 619488da5f222..1cd517c23fbcc 100644 --- a/python_modules/dagster/dagster/_core/definitions/metadata/metadata_set.py +++ b/python_modules/dagster/dagster/_core/definitions/metadata/metadata_set.py @@ -62,27 +62,27 @@ def __getitem__(self, key: str) -> Any: return getattr(self, self._strip_namespace_from_key(key)) @classmethod - def extract(cls: Type[T_NamespacedKVSet], metadata: Mapping[str, Any]) -> T_NamespacedKVSet: - """Extracts entries from the provided metadata dictionary into an instance of this class. + def extract(cls: Type[T_NamespacedKVSet], values: Mapping[str, Any]) -> T_NamespacedKVSet: + """Extracts entries from the provided dictionary into an instance of this class. - Ignores any entries in the metadata dictionary whose keys don't correspond to fields on this + Ignores any entries in the dictionary whose keys don't correspond to fields on this class. In general, the following should always pass: .. code-block:: python - class MyMetadataSet(NamedspacedMetadataSet): + class MyKVSet(NamespacedKVSet): ... - metadata: MyMetadataSet = ... - assert MyMetadataSet.extract(dict(metadata)) == metadata + metadata: MyKVSet = ... + assert MyKVSet.extract(dict(metadata)) == metadata Args: - metadata (Mapping[str, Any]): A dictionary of metadata entries. + values (Mapping[str, Any]): A dictionary of entries to extract. """ kwargs = {} - for namespaced_key, value in metadata.items(): + for namespaced_key, value in values.items(): splits = namespaced_key.split("/") if len(splits) == 2: namespace, key = splits diff --git a/python_modules/dagster/dagster/_core/definitions/tags/tag_set.py b/python_modules/dagster/dagster/_core/definitions/tags/tag_set.py index 5457ce467b05f..5968adabc29bc 100644 --- a/python_modules/dagster/dagster/_core/definitions/tags/tag_set.py +++ b/python_modules/dagster/dagster/_core/definitions/tags/tag_set.py @@ -1,4 +1,4 @@ -from typing import Any +from typing import Any, cast from typing_extensions import TypeVar, get_args @@ -40,6 +40,6 @@ def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) @classmethod - def _extract_value(cls, field_name: str, value: Any) -> Any: + def _extract_value(cls, field_name: str, value: Any) -> str: """Since all tag values are strings, we don't need to do any type coercion.""" - return value + return cast(str, value)