-
Notifications
You must be signed in to change notification settings - Fork 905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add official support for Python 3.12 #3587
Changes from 6 commits
cc28696
74705b8
4dc83f2
d01541f
43ab544
afa5b1b
62481cc
d544384
f459d2f
9afc366
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -401,6 +401,7 @@ def test_empty_catalog_file(self, tmp_path): | |
)["catalog"] | ||
assert catalog == {} | ||
|
||
@pytest.mark.xfail(reason="Logic failing") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed the test to check for the intended behaviour. However, it fails, and manual testing shows that this is due to the implementation of the OmegaConfigLoader. I would suggest correcting this should be split out into a separate issue to be addressed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't agree with this being addressed in a separate issue, adding the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not the move to include 3.12 that's causing this test to fail, but rather it was never truly passing, the previous method call used for the assert was mistyped, leading to a trivial pass. To resolve this requires digging further into the implementation of the OmegaConfigLoader, as it is not behaving as expected, and perhaps never was. See xref. |
||
def test_overlapping_patterns(self, tmp_path, mocker): | ||
"""Check that same configuration file is not loaded more than once.""" | ||
_write_yaml( | ||
|
@@ -421,23 +422,27 @@ def test_overlapping_patterns(self, tmp_path, mocker): | |
] | ||
} | ||
|
||
catalog = OmegaConfigLoader( | ||
conf_source=str(tmp_path), | ||
base_env=_BASE_ENV, | ||
env="dev", | ||
config_patterns=catalog_patterns, | ||
)["catalog"] | ||
expected_catalog = { | ||
"env": "dev", | ||
"common": "common", | ||
"dev_specific": "wiz", | ||
"user1_c2": True, | ||
} | ||
assert catalog == expected_catalog | ||
# Use a mocked function to keep track of function calls | ||
with mocker.patch( | ||
"omegaconf.OmegaConf.load", wraps=OmegaConf.load | ||
) as mocked_load: | ||
AhdraMeraliQB marked this conversation as resolved.
Show resolved
Hide resolved
|
||
catalog = OmegaConfigLoader( | ||
conf_source=str(tmp_path), | ||
base_env=_BASE_ENV, | ||
env="dev", | ||
config_patterns=catalog_patterns, | ||
)["catalog"] | ||
expected_catalog = { | ||
"env": "dev", | ||
"common": "common", | ||
"dev_specific": "wiz", | ||
"user1_c2": True, | ||
} | ||
assert catalog == expected_catalog | ||
|
||
mocked_load = mocker.patch("omegaconf.OmegaConf.load") | ||
expected_path = (tmp_path / "dev" / "user1" / "catalog2.yml").resolve() | ||
assert mocked_load.called_once_with(expected_path) | ||
# Assert any specific config file was only loaded once | ||
expected_path = (tmp_path / "dev" / "user1" / "catalog2.yml").resolve() | ||
mocked_load.assert_called_once_with(expected_path) | ||
|
||
def test_yaml_parser_error(self, tmp_path): | ||
conf_path = tmp_path / _BASE_ENV | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See this issue, the UserDict's get implementation in 3.12 doesn't work for the config loader anymore, so the method is overwritten to use the get function from the previous python versions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will make the comment in the file more clearDone!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be on OmegaConfigLoader or the abstract method? I am slightly confused why
get
method is needed for OmegaConf.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went for the AbstractConfigLoader to catch any cases where users have defined their own Config Loaders (for whatever reason) that inherit from the AbstractConfigLoader.
Whilst we don't promote using get over the dict syntax, we have made it available - and it features in our API docs - allowing users to do something like:
Ultimately, removing get() is a breaking change, which would block adding 3.12 support until the next major release.