99from hydra .core .object_type import ObjectType
1010from hydra .plugins .config_source import ConfigLoadError , ConfigResult , ConfigSource
1111
12- # Relevant issue: https://github.com/python/mypy/issues/1153
13- # Python 3.9+ has importlib.resources in the standard library
14-
1512
1613class ImportlibResourcesConfigSource (ConfigSource ):
1714 def __init__ (self , provider : str , path : str ) -> None :
@@ -51,7 +48,7 @@ def _read_config(self, res: Any) -> ConfigResult:
5148 def load_config (self , config_path : str ) -> ConfigResult :
5249 normalized_config_path = self ._normalize_file_name (config_path )
5350 res = resources .files (self .path ).joinpath (normalized_config_path )
54- if not res .exists ( ):
51+ if not ( res .is_file () or res . is_dir () ):
5552 raise ConfigLoadError (f"Config not found : { normalized_config_path } " )
5653
5754 return self ._read_config (res )
@@ -70,7 +67,7 @@ def is_group(self, config_path: str) -> bool:
7067 return False
7168
7269 res = files .joinpath (config_path )
73- ret = res .exists () and res . is_dir ()
70+ ret = res .is_dir ()
7471 assert isinstance (ret , bool )
7572 return ret
7673
@@ -81,7 +78,7 @@ def is_config(self, config_path: str) -> bool:
8178 except (ValueError , ModuleNotFoundError , TypeError ):
8279 return False
8380 res = files .joinpath (config_path )
84- ret = res .exists () and res . is_file ()
81+ ret = res .is_file ()
8582 assert isinstance (ret , bool )
8683 return ret
8784
0 commit comments