diff --git a/tensorflow_datasets/core/community/config.py b/tensorflow_datasets/core/community/config.py index fcd5bc1becb..c5a66c5171c 100644 --- a/tensorflow_datasets/core/community/config.py +++ b/tensorflow_datasets/core/community/config.py @@ -19,6 +19,7 @@ import dataclasses import functools import threading +import tomllib from typing import Any from absl import logging @@ -27,7 +28,6 @@ # understands paths that start with github://. from tensorflow_datasets.core import github_api # pylint: disable=unused-import from tensorflow_datasets.core.utils import resource_utils -import toml @dataclasses.dataclass(frozen=True) @@ -90,7 +90,7 @@ def _initialize_config_per_namespace(self) -> None: # meantime, so check again whether it's initialized. if not self._is_config_per_namespace_initialized: logging.info('Loading namespace config from %s', self.config_path) - raw_config = toml.loads(self.config_path.read_text()) + raw_config = tomllib.loads(self.config_path.read_text()) for namespace, raw_namespace_config in raw_config.items(): namespace_config = _load_config(config=raw_namespace_config) self.add_namespace(namespace, namespace_config) diff --git a/tensorflow_datasets/scripts/deployment/export_community_datasets_test.py b/tensorflow_datasets/scripts/deployment/export_community_datasets_test.py index 80c422d7c37..d0d22eca47b 100644 --- a/tensorflow_datasets/scripts/deployment/export_community_datasets_test.py +++ b/tensorflow_datasets/scripts/deployment/export_community_datasets_test.py @@ -18,10 +18,10 @@ import pathlib import string import textwrap +import tomllib from typing import Dict, List from tensorflow_datasets.scripts.deployment import export_community_datasets -import toml def _write_dataset_files( @@ -92,5 +92,5 @@ def test_export_community_datasets(tmp_path): def test_toml_valid(): """Makes sure that reading the `.toml` file is valid.""" - config = toml.load(export_community_datasets._IN_PATH) + config = tomllib.loads(export_community_datasets._IN_PATH.read_text()) _ = {namespace: ns_config for namespace, ns_config in config.items()}