Skip to content

Commit 8d9b721

Browse files
authored
Merge pull request #1853 from braingram/err_select_tag
Error for Convert subclasses with multiple tags if select_tag isn't implemented
2 parents f3f6070 + 583034e commit 8d9b721

File tree

3 files changed

+5
-23
lines changed

3 files changed

+5
-23
lines changed

asdf/_tests/test_extension.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import asdf
88
from asdf import AsdfFile, config_context
9-
from asdf.exceptions import AsdfManifestURIMismatchWarning, AsdfSerializationError, AsdfWarning, ValidationError
9+
from asdf.exceptions import AsdfManifestURIMismatchWarning, AsdfSerializationError, ValidationError
1010
from asdf.extension import (
1111
Compressor,
1212
Converter,
@@ -892,10 +892,8 @@ def from_yaml_tree(self, node, tag, ctx):
892892
"asdf://somewhere.org/tags/foo-2.0.0",
893893
]
894894
extension = FullExtension(converters=[FooConverter()], tags=tags)
895-
ctx_type = pytest.warns if is_subclass else pytest.raises
896-
exception_class = AsdfWarning if is_subclass else RuntimeError
897895
with config_context() as config:
898-
with ctx_type(exception_class, match="Converter handles multiple tags"):
896+
with pytest.raises(RuntimeError, match="Converter handles multiple tags"):
899897
config.add_extension(extension)
900898

901899

asdf/extension/_converter.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
"""
55

66
import abc
7-
import warnings
87

9-
from asdf.exceptions import AsdfWarning
108
from asdf.util import get_class_name, uri_match
119

1210

@@ -179,23 +177,8 @@ def __init__(self, delegate, extension):
179177
raise TypeError(msg)
180178

181179
if len(relevant_tags) > 1 and not hasattr(delegate, "select_tag"):
182-
# we cannot use isinstance here because Converter supports
183-
# virtual subclasses
184-
if Converter in delegate.__class__.__mro__:
185-
# prior to asdf 3.0 Converter provided a default select_tag
186-
# to provide backwards compatibility allow Converter subclasses
187-
# to be registered with >1 tag but produce a warning
188-
msg = (
189-
"Converter handles multiple tags for this extension, "
190-
"but does not implement a select_tag method. "
191-
"This previously worked because Converter subclasses inherited "
192-
"the now removed select_tag. This will be an error in a future "
193-
"version of asdf"
194-
)
195-
warnings.warn(msg, AsdfWarning)
196-
else:
197-
msg = "Converter handles multiple tags for this extension, but does not implement a select_tag method."
198-
raise RuntimeError(msg)
180+
msg = "Converter handles multiple tags for this extension, but does not implement a select_tag method."
181+
raise RuntimeError(msg)
199182

200183
self._tags = sorted(relevant_tags)
201184

changes/1853.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Raise RuntimeError if a Convert subclass supports multiple tags but doesn't implement select_tag.

0 commit comments

Comments
 (0)