Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions hydra/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ def __init__(


class HydraDeprecationError(HydraException): ...


class UnsupportedExtensionException(HydraException): ...

Check notice

Code scanning / CodeQL

Statement has no effect

This statement has no effect.
9 changes: 7 additions & 2 deletions hydra/plugins/config_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from hydra._internal.deprecation_warning import deprecation_warning
from hydra.core.default_element import InputDefault
from hydra.core.object_type import ObjectType
from hydra.errors import HydraException
from hydra.errors import HydraException, UnsupportedExtensionException
from hydra.plugins.plugin import Plugin


Expand Down Expand Up @@ -116,7 +116,12 @@ def full_path(self) -> str:
@staticmethod
def _normalize_file_name(filename: str) -> str:
supported_extensions = [".yaml"]
if not version.base_at_least("1.2"):
if version.base_at_least("1.2"):
if filename.endswith(".yml"):
raise UnsupportedExtensionException(
".yml files are not supported. Use .yaml extension for Hydra config files."
)
else:
supported_extensions.append(".yml")
if filename.endswith(".yml"):
deprecation_warning(
Expand Down
7 changes: 7 additions & 0 deletions tests/test_config_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
ConfigCompositionException,
HydraException,
MissingConfigException,
UnsupportedExtensionException,
)
from hydra.test_utils.test_utils import chdir_hydra_root
from hydra.types import RunMode
Expand Down Expand Up @@ -190,6 +191,12 @@ def test_load_yml_file(self, path: str, hydra_restore_singletons: Any) -> None:
config_loader = ConfigLoaderImpl(
config_search_path=create_config_search_path(path)
)
with raises(UnsupportedExtensionException):
cfg = config_loader.load_configuration(

Check warning

Code scanning / CodeQL

Variable defined multiple times

This assignment to 'cfg' is unnecessary as it is [redefined](1) before this value is used.
config_name="config.yml",
overrides=[],
run_mode=RunMode.RUN,
)
version.setbase("1.1")
with warns(
UserWarning,
Expand Down