Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deprecate ignore_version_mismatch
Browse files Browse the repository at this point in the history
braingram committed Aug 7, 2024
1 parent d05d388 commit 60462b0
Showing 2 changed files with 20 additions and 11 deletions.
13 changes: 10 additions & 3 deletions asdf/_asdf.py
Original file line number Diff line number Diff line change
@@ -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=False,
@@ -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.
@@ -165,7 +166,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

@@ -1615,7 +1621,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=False,
@@ -1653,6 +1659,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.
18 changes: 10 additions & 8 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
@@ -44,7 +45,6 @@ def pytest_addoption(parser):
"asdf_schema_ignore_version_mismatch",
"Set to true to disable warnings when missing explicit support for a tag",
type="bool",
default=True,
)
parser.addoption("--asdf-tests", action="store_true", help="Enable ASDF schema tests")

@@ -59,7 +59,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 +74,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 +99,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 +191,6 @@ def from_parent(
example,
example_index,
ignore_unrecognized_tag=False,
ignore_version_mismatch=False,
**kwargs,
):
if hasattr(super(), "from_parent"):
@@ -206,7 +202,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 +215,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 +282,15 @@ 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 in (True, False):
from asdf.exceptions import AsdfDeprecationWarning

# pytest will return an empty list for getini on a bool with no default
# since we have a True or False here warn the user that this setting is deprecated
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 +318,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,
)

0 comments on commit 60462b0

Please sign in to comment.