Skip to content

Commit

Permalink
Merge pull request #1595 from braingram/schema_uri
Browse files Browse the repository at this point in the history
remove deprecated TagDefinition.schema_uri
  • Loading branch information
braingram committed Aug 7, 2023
2 parents b1540cd + 3369028 commit 27c4a5b
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 41 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The ASDF Standard is at v1.6.0
by returning ``None`` in ``Converter.select_tag`` [#1561]
- Remove deprecated tests.helpers [#1597]
- Remove deprecated load_custom_schema [#1596]
- Remove deprecated TagDefinition.schema_uri [#1595]

2.15.1 (2023-08-07)
-------------------
Expand Down
8 changes: 0 additions & 8 deletions asdf/_tests/test_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,6 @@ def test_tag_definition():

assert "URI: asdf://somewhere.org/extensions/foo/tags/foo-1.0" in repr(tag_def)

with pytest.warns(AsdfDeprecationWarning, match=r"The .* property is deprecated.*"):
assert tag_def.schema_uri == "asdf://somewhere.org/extensions/foo/schemas/foo-1.0"

tag_def = TagDefinition(
"asdf://somewhere.org/extensions/foo/tags/foo-1.0",
schema_uris=[
Expand All @@ -479,11 +476,6 @@ def test_tag_definition():
"asdf://somewhere.org/extensions/foo/schemas/foo-1.0",
"asdf://somewhere.org/extensions/foo/schemas/base-1.0",
]
with pytest.warns(AsdfDeprecationWarning, match=r"The .* property is deprecated.*"), pytest.raises(
RuntimeError,
match=r"Cannot use .* when multiple schema URIs are present",
):
tag_def.schema_uri

with pytest.raises(ValueError, match=r"URI patterns are not permitted in TagDefinition"):
TagDefinition("asdf://somewhere.org/extensions/foo/tags/foo-*")
Expand Down
33 changes: 1 addition & 32 deletions asdf/extension/_tag.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import warnings

from asdf.exceptions import AsdfDeprecationWarning


class TagDefinition:
"""
Container for properties of a custom YAML tag.
Expand All @@ -11,7 +6,7 @@ class TagDefinition:
----------
tag_uri : str
Tag URI.
schema_uri : str, optional
schema_uris : str, optional
URI of the schema that should be used to validate objects
with this tag.
title : str, optional
Expand Down Expand Up @@ -50,32 +45,6 @@ def tag_uri(self):
"""
return self._tag_uri

@property
def schema_uri(self):
"""
DEPRECATED
Get the URI of the schema that should be used to validate
objects with this tag.
Returns
-------
str or None
"""
warnings.warn(
"The TagDefinition.schema_uri property is deprecated. Use TagDefinition.schema_uris instead.",
AsdfDeprecationWarning,
)

if len(self._schema_uris) == 0:
return None

if len(self._schema_uris) == 1:
return self._schema_uris[0]

msg = "Cannot use TagDefinition.schema_uri when multiple schema URIs are present"
raise RuntimeError(msg)

@property
def schema_uris(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion docs/asdf/extending/extensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ instead of just a string:
tags = [
TagDefinition(
"asdf://example.com/example-project/tags/foo-1.0.0",
schema_uri="asdf://example.com/example-project/schemas/foo-1.0.0",
schema_uris=["asdf://example.com/example-project/schemas/foo-1.0.0"],
)
]
converters = [FooConverter()]
Expand Down

0 comments on commit 27c4a5b

Please sign in to comment.