Skip to content

Commit

Permalink
remove legacy extension api deprecated AsdfFile methods/attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram committed Mar 6, 2023
1 parent 7d73fa6 commit ae4d504
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 144 deletions.
6 changes: 2 additions & 4 deletions asdf/_tests/commands/tests/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from asdf import AsdfFile
from asdf.commands import list_tags
from asdf.exceptions import AsdfDeprecationWarning


@pytest.mark.parametrize("display_classes", [True, False])
Expand All @@ -20,8 +19,7 @@ def test_all_tags_present():
tags = {line.strip() for line in iostream.readlines()}

af = AsdfFile()
with pytest.warns(AsdfDeprecationWarning, match="AsdfFile.type_index is deprecated"):
for tag in af.type_index._type_by_tag:
assert tag in tags
for tag in af._type_index._type_by_tag:
assert tag in tags
for tag in af.extension_manager._converters_by_tag:
assert tag in tags
4 changes: 1 addition & 3 deletions asdf/_tests/tags/core/tests/test_ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from asdf import util
from asdf._tests import _helpers as helpers
from asdf._tests.objects import CustomTestType
from asdf.exceptions import AsdfDeprecationWarning
from asdf.tags.core import ndarray

from . import data as test_data
Expand Down Expand Up @@ -131,8 +130,7 @@ def test_dont_load_data():

buff.seek(0)
with asdf.open(buff) as ff:
with pytest.warns(AsdfDeprecationWarning, match="AsdfFile.run_hook is deprecated"):
ff.run_hook("reserve_blocks")
ff._run_hook("reserve_blocks")

# repr and str shouldn't load data
str(ff.tree["science_data"])
Expand Down
10 changes: 0 additions & 10 deletions asdf/_tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,6 @@ def test_copy(tmp_path):
assert_array_equal(ff2.tree["my_array"], ff2.tree["my_array"])


def test_tag_to_schema_resolver_deprecation():
ff = asdf.AsdfFile()
with pytest.warns(AsdfDeprecationWarning):
ff.tag_to_schema_resolver("foo")

with pytest.warns(AsdfDeprecationWarning):
extension_list = _legacy_extension.default_extensions.extension_list
extension_list.tag_to_schema_resolver("foo")


def test_access_tree_outside_handler(tmp_path):
tempname = str(tmp_path / "test.asdf")

Expand Down
16 changes: 0 additions & 16 deletions asdf/_tests/test_deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,6 @@ def test_assert_extension_correctness_deprecation():
assert_extension_correctness(extension)


@pytest.mark.parametrize("attr", ["url_mapping", "tag_mapping", "resolver", "extension_list", "type_index"])
def test_asdffile_legacy_extension_api_attr_deprecations(attr):
with asdf.AsdfFile() as af, pytest.warns(AsdfDeprecationWarning, match=f"AsdfFile.{attr} is deprecated"):
getattr(af, attr)


def test_asdfile_run_hook_deprecation():
with asdf.AsdfFile() as af, pytest.warns(AsdfDeprecationWarning, match="AsdfFile.run_hook is deprecated"):
af.run_hook("foo")


def test_asdfile_run_modifying_hook_deprecation():
with asdf.AsdfFile() as af, pytest.warns(AsdfDeprecationWarning, match="AsdfFile.run_modifying_hook is deprecated"):
af.run_modifying_hook("foo")


def test_asdf_type_format_tag():
with pytest.warns(AsdfDeprecationWarning, match="asdf.types.format_tag is deprecated"):
asdf._types.format_tag
Expand Down
5 changes: 2 additions & 3 deletions asdf/_tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,8 @@ def test_asdf_file_resolver_hashing():
a1 = asdf.AsdfFile()
a2 = asdf.AsdfFile()

with pytest.warns(AsdfDeprecationWarning, match="AsdfFile.resolver is deprecated"):
assert hash(a1.resolver) == hash(a2.resolver)
assert a1.resolver == a2.resolver
assert hash(a1._resolver) == hash(a2._resolver)
assert a1._resolver == a2._resolver


def test_load_schema_from_resource_mapping():
Expand Down
108 changes: 0 additions & 108 deletions asdf/asdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,23 +255,6 @@ def extension_manager(self):
self._extension_manager = get_cached_extension_manager(self._user_extensions + self._plugin_extensions)
return self._extension_manager

@property
def extension_list(self):
"""
Get the AsdfExtensionList for this AsdfFile.
Returns
-------
asdf.extension.AsdfExtensionList
"""
warnings.warn(
"AsdfFile.extension_list is deprecated. "
"Please see the new extension API "
"https://asdf.readthedocs.io/en/stable/asdf/extending/converters.html",
AsdfDeprecationWarning,
)
return self._extension_list

@property
def _extension_list(self):
if self._extension_list_ is None:
Expand Down Expand Up @@ -499,70 +482,22 @@ def uri(self):
return self._fd._uri
return None

@property
def tag_to_schema_resolver(self):
warnings.warn(
"The 'tag_to_schema_resolver' property is deprecated. Use 'tag_mapping' instead.",
AsdfDeprecationWarning,
)
return self._tag_to_schema_resolver

@property
def _tag_to_schema_resolver(self):
return self._extension_list.tag_mapping

@property
def tag_mapping(self):
warnings.warn(
"AsdfFile.tag_mapping is deprecated. "
"Please see Manifests "
"https://asdf.readthedocs.io/en/stable/asdf/extending/manifests.html",
AsdfDeprecationWarning,
)
return self._tag_mapping

@property
def _tag_mapping(self):
return self._extension_list.tag_mapping

@property
def url_mapping(self):
warnings.warn(
"AsdfFile.url_mapping is deprecated. "
"Please see Resources "
"https://asdf.readthedocs.io/en/stable/asdf/extending/resources.html",
AsdfDeprecationWarning,
)
return self._url_mapping

@property
def _url_mapping(self):
return self._extension_list.url_mapping

@property
def resolver(self):
warnings.warn(
"AsdfFile.resolver is deprecated. "
"Please see Resources "
"https://asdf.readthedocs.io/en/stable/asdf/extending/resources.html",
AsdfDeprecationWarning,
)
return self._resolver

@property
def _resolver(self):
return self._extension_list.resolver

@property
def type_index(self):
warnings.warn(
"AsdfFile.type_index is deprecated. "
"Please see the new extension API "
"https://asdf.readthedocs.io/en/stable/asdf/extending/converters.html",
AsdfDeprecationWarning,
)
return self._type_index

@property
def _type_index(self):
return self._extension_list.type_index
Expand Down Expand Up @@ -1458,25 +1393,6 @@ def resolve_references(self, **kwargs):
# tree will be validated.
self.tree = reference.resolve_references(self._tree, self)

def run_hook(self, hookname):
"""
Run a "hook" for each custom type found in the tree.
Parameters
----------
hookname : str
The name of the hook. If a `asdf.types.AsdfType` is found with a method
with this name, it will be called for every instance of the
corresponding custom type in the tree.
"""
warnings.warn(
"AsdfFile.run_hook is deprecated. "
"Please see the new extension API "
"https://asdf.readthedocs.io/en/stable/asdf/extending/converters.html",
AsdfDeprecationWarning,
)
self._run_hook(hookname)

def _run_hook(self, hookname):
type_index = self._type_index

Expand All @@ -1488,30 +1404,6 @@ def _run_hook(self, hookname):
if hook is not None:
hook(node, self)

def run_modifying_hook(self, hookname, validate=True):
"""
Run a "hook" for each custom type found in the tree. The hook
is free to return a different object in order to modify the
tree.
Parameters
----------
hookname : str
The name of the hook. If a `asdf.types.AsdfType` is found with a method
with this name, it will be called for every instance of the
corresponding custom type in the tree.
validate : bool
When `True` (default) validate the resulting tree.
"""
warnings.warn(
"AsdfFile.run_modifying_hook is deprecated. "
"Please see the new extension API "
"https://asdf.readthedocs.io/en/stable/asdf/extending/converters.html",
AsdfDeprecationWarning,
)
return self._run_modifying_hook(hookname, validate=validate)

def _run_modifying_hook(self, hookname, validate=True):
type_index = self._type_index

Expand Down

0 comments on commit ae4d504

Please sign in to comment.