diff --git a/asdf/_asdf.py b/asdf/_asdf.py index ba3ddab61..40b2971ac 100644 --- a/asdf/_asdf.py +++ b/asdf/_asdf.py @@ -72,7 +72,7 @@ def __init__( uri=None, extensions=None, version=None, - ignore_version_mismatch=True, + ignore_version_mismatch=NotSet, ignore_unrecognized_tag=False, ignore_implicit_conversion=NotSet, copy_arrays=NotSet, @@ -102,6 +102,7 @@ def __init__( configured default version. See `asdf.config.AsdfConfig.default_version`. ignore_version_mismatch : bool, optional + Deprecated and unused. This setting does nothing since asdf 3.0.0 When `True`, do not raise warnings for mismatched schema versions. Set to `True` by default. @@ -162,7 +163,12 @@ def __init__( else: self._custom_schema = None - self._ignore_version_mismatch = ignore_version_mismatch + if ignore_version_mismatch is not NotSet: + warnings.warn( + "ignore_version_mismatch is deprecated and has done nothing since asdf 3.0.0", + AsdfDeprecationWarning, + ) + self._ignore_unrecognized_tag = ignore_unrecognized_tag self._ignore_implicit_conversion = ignore_implicit_conversion @@ -1619,7 +1625,7 @@ def open_asdf( mode=None, validate_checksums=False, extensions=None, - ignore_version_mismatch=True, + ignore_version_mismatch=NotSet, ignore_unrecognized_tag=False, _force_raw_types=False, copy_arrays=NotSet, @@ -1657,6 +1663,7 @@ def open_asdf( May be an `asdf.extension.Extension` or a `list` of extensions. ignore_version_mismatch : bool, optional + Deprecated and unused. This setting does nothing since asdf 3.0.0 When `True`, do not raise warnings for mismatched schema versions. Set to `True` by default. diff --git a/asdf/_tests/test_deprecated.py b/asdf/_tests/test_deprecated.py index 55bb02d13..09a7a3a99 100644 --- a/asdf/_tests/test_deprecated.py +++ b/asdf/_tests/test_deprecated.py @@ -158,3 +158,9 @@ def test_copy_arrays_deprecation(copy_arrays, memmap, tmp_path): with pytest.warns(AsdfWarning, match="copy_arrays is deprecated; use memmap instead"): with asdf.open(fn, copy_arrays=copy_arrays, memmap=memmap) as af: pass + + +@pytest.mark.parametrize("value", [True, False]) +def test_ignore_version_mismatch_deprecation(value): + with pytest.warns(AsdfDeprecationWarning, match="ignore_version_mismatch is deprecated"): + asdf.AsdfFile({}, ignore_version_mismatch=value) diff --git a/changes/1819.removal.rst b/changes/1819.removal.rst new file mode 100644 index 000000000..881fe2444 --- /dev/null +++ b/changes/1819.removal.rst @@ -0,0 +1,2 @@ +Deprecate ``ignore_version_mismatch``. This option has done nothing since +asdf 3.0.0 and will be removed in an upcoming asdf version diff --git a/pytest_asdf/plugin.py b/pytest_asdf/plugin.py index bccdf3e8a..6f5e60e7a 100644 --- a/pytest_asdf/plugin.py +++ b/pytest_asdf/plugin.py @@ -1,6 +1,7 @@ import io import os import pathlib +import warnings from dataclasses import dataclass import numpy as np @@ -43,8 +44,8 @@ def pytest_addoption(parser): parser.addini( "asdf_schema_ignore_version_mismatch", "Set to true to disable warnings when missing explicit support for a tag", - type="bool", - default=True, + type="string", + default="", ) parser.addoption("--asdf-tests", action="store_true", help="Enable ASDF schema tests") @@ -59,7 +60,6 @@ def from_parent( skip_examples=False, validate_default=True, ignore_unrecognized_tag=False, - ignore_version_mismatch=False, skip_tests=None, xfail_tests=None, **kwargs, @@ -75,7 +75,6 @@ def from_parent( result.skip_examples = skip_examples result.validate_default = validate_default result.ignore_unrecognized_tag = ignore_unrecognized_tag - result.ignore_version_mismatch = ignore_version_mismatch result.skip_tests = [] if skip_tests is None else skip_tests result.xfail_tests = [] if xfail_tests is None else xfail_tests @@ -101,7 +100,6 @@ def collect(self): example, index, ignore_unrecognized_tag=self.ignore_unrecognized_tag, - ignore_version_mismatch=self.ignore_version_mismatch, name=name, ) self._set_markers(item) @@ -194,7 +192,6 @@ def from_parent( example, example_index, ignore_unrecognized_tag=False, - ignore_version_mismatch=False, **kwargs, ): if hasattr(super(), "from_parent"): @@ -206,7 +203,6 @@ def from_parent( result.filename = str(schema_path) result.example = SchemaExample.from_schema(example) result.ignore_unrecognized_tag = ignore_unrecognized_tag - result.ignore_version_mismatch = ignore_version_mismatch return result def runtest(self): @@ -220,7 +216,6 @@ def runtest(self): ff = AsdfFile( uri=pathlib.Path(self.filename).expanduser().absolute().as_uri(), ignore_unrecognized_tag=self.ignore_unrecognized_tag, - ignore_version_mismatch=self.ignore_version_mismatch, ) # Fake an external file @@ -288,6 +283,13 @@ def pytest_collect_file(file_path, parent): validate_default = parent.config.getini("asdf_schema_validate_default") ignore_unrecognized_tag = parent.config.getini("asdf_schema_ignore_unrecognized_tag") ignore_version_mismatch = parent.config.getini("asdf_schema_ignore_version_mismatch") + if ignore_version_mismatch != "": + from asdf.exceptions import AsdfDeprecationWarning + + warnings.warn( + "asdf_schema_ignore_version_mismatch is deprecated and has done nothing since asdf 3.0.0", + AsdfDeprecationWarning, + ) skip_tests = _parse_test_list(parent.config.getini("asdf_schema_skip_tests")) xfail_tests = _parse_test_list(parent.config.getini("asdf_schema_xfail_tests")) @@ -315,7 +317,6 @@ def pytest_collect_file(file_path, parent): skip_examples=(file_path.stem in skip_examples), validate_default=validate_default, ignore_unrecognized_tag=ignore_unrecognized_tag, - ignore_version_mismatch=ignore_version_mismatch, skip_tests=schema_skip_tests, xfail_tests=schema_xfail_tests, )