Skip to content
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

deprecate ignore_version_mismatch #1819

Merged
Merged
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
13 changes: 10 additions & 3 deletions asdf/_asdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
zacharyburnett marked this conversation as resolved.
Show resolved Hide resolved
When `True`, do not raise warnings for mismatched schema versions.
Set to `True` by default.

Expand Down Expand Up @@ -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",
zacharyburnett marked this conversation as resolved.
Show resolved Hide resolved
AsdfDeprecationWarning,
)

self._ignore_unrecognized_tag = ignore_unrecognized_tag
self._ignore_implicit_conversion = ignore_implicit_conversion

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
zacharyburnett marked this conversation as resolved.
Show resolved Hide resolved
When `True`, do not raise warnings for mismatched schema versions.
Set to `True` by default.

Expand Down
6 changes: 6 additions & 0 deletions asdf/_tests/test_deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
zacharyburnett marked this conversation as resolved.
Show resolved Hide resolved
asdf.AsdfFile({}, ignore_version_mismatch=value)
2 changes: 2 additions & 0 deletions changes/1819.removal.rst
Original file line number Diff line number Diff line change
@@ -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
19 changes: 10 additions & 9 deletions pytest_asdf/plugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import io
import os
import pathlib
import warnings
from dataclasses import dataclass

import numpy as np
Expand Down Expand Up @@ -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")

Expand All @@ -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,
Expand All @@ -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

Expand All @@ -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)
Expand Down Expand Up @@ -194,7 +192,6 @@ def from_parent(
example,
example_index,
ignore_unrecognized_tag=False,
ignore_version_mismatch=False,
**kwargs,
):
if hasattr(super(), "from_parent"):
Expand All @@ -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):
Expand All @@ -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
Expand Down Expand Up @@ -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",
zacharyburnett marked this conversation as resolved.
Show resolved Hide resolved
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"))
Expand Down Expand Up @@ -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,
)
Expand Down
Loading