diff --git a/src/datasets/formatting/tf_formatter.py b/src/datasets/formatting/tf_formatter.py index 16ad7b185c2..adb15cda381 100644 --- a/src/datasets/formatting/tf_formatter.py +++ b/src/datasets/formatting/tf_formatter.py @@ -33,7 +33,7 @@ class TFFormatter(TensorFormatter[Mapping, "tf.Tensor", Mapping]): def __init__(self, features=None, **tf_tensor_kwargs): super().__init__(features=features) self.tf_tensor_kwargs = tf_tensor_kwargs - import tensorflow as tf # noqa: import tf at initialization + import tensorflow as tf # noqa: F401 - import tf at initialization def _consolidate(self, column): import tensorflow as tf diff --git a/src/datasets/load.py b/src/datasets/load.py index 88f9b05fe13..3e24f7e1cbc 100644 --- a/src/datasets/load.py +++ b/src/datasets/load.py @@ -1173,7 +1173,7 @@ def dataset_module_factory( token=download_config.token, timeout=100.0, ) - except Exception as e: # noqa: catch any exception of hf_hub and consider that the dataset doesn't exist + except Exception as e: # noqa catch any exception of hf_hub and consider that the dataset doesn't exist if isinstance( e, ( @@ -1213,10 +1213,10 @@ def dataset_module_factory( ).get_module() except ( Exception - ) as e1: # noqa: all the attempts failed, before raising the error we should check if the module is already cached. + ) as e1: # noqa all the attempts failed, before raising the error we should check if the module is already cached. try: return CachedDatasetModuleFactory(path, dynamic_modules_path=dynamic_modules_path).get_module() - except Exception as e2: # noqa: if it's not in the cache, then it doesn't exist. + except Exception: # noqa if it's not in the cache, then it doesn't exist. if isinstance(e1, OfflineModeIsEnabled): raise ConnectionError(f"Couldn't reach the Hugging Face Hub for dataset '{path}': {e1}") from None if isinstance(e1, EmptyDatasetError): @@ -1318,10 +1318,10 @@ def metric_module_factory( ).get_module() except ( Exception - ) as e1: # noqa: all the attempts failed, before raising the error we should check if the module is already cached. + ) as e1: # noqa all the attempts failed, before raising the error we should check if the module is already cached. try: return CachedMetricModuleFactory(path, dynamic_modules_path=dynamic_modules_path).get_module() - except Exception as e2: # noqa: if it's not in the cache, then it doesn't exist. + except Exception: # noqa if it's not in the cache, then it doesn't exist. if not isinstance(e1, FileNotFoundError): raise e1 from None raise FileNotFoundError( diff --git a/src/datasets/search.py b/src/datasets/search.py index 091413c3bf4..890043a1261 100644 --- a/src/datasets/search.py +++ b/src/datasets/search.py @@ -120,7 +120,7 @@ def __init__( host = host or "localhost" port = port or 9200 - import elasticsearch.helpers # noqa: need this to properly load all the es features + import elasticsearch.helpers # noqa: F401 - need this to properly load all the es features from elasticsearch import Elasticsearch # noqa: F811 self.es_client = es_client if es_client is not None else Elasticsearch([{"host": host, "port": str(port)}]) diff --git a/tests/_test_patching.py b/tests/_test_patching.py index cb00b2848fd..dae9a419ec0 100644 --- a/tests/_test_patching.py +++ b/tests/_test_patching.py @@ -2,12 +2,12 @@ # This is the module that test_patching.py uses to test patch_submodule() -import os # noqa: this is just for tests -import os as renamed_os # noqa: this is just for tests -from os import path # noqa: this is just for tests -from os import path as renamed_path # noqa: this is just for tests -from os.path import join # noqa: this is just for tests -from os.path import join as renamed_join # noqa: this is just for tests +import os # noqa: F401 - this is just for tests +import os as renamed_os # noqa: F401 - this is just for tests +from os import path # noqa: F401 - this is just for tests +from os import path as renamed_path # noqa: F401 - this is just for tests +from os.path import join # noqa: F401 - this is just for tests +from os.path import join as renamed_join # noqa: F401 - this is just for tests -open = open # noqa: we just need to have a builtin inside this module to test it properly +open = open # noqa we just need to have a builtin inside this module to test it properly