-
Notifications
You must be signed in to change notification settings - Fork 68
Add warning when conversion fails with default warn_on_failed_conversion
#2125
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
Merged
sydduckworth
merged 16 commits into
asdf-format:main
from
sydduckworth:warn-on-warn-on-failed-conversion-2
Sep 2, 2026
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
90c9f16
Added `tracked_property` decorator for tracking whether a property has
sydduckworth e464e34
Added warning when `warn_on_failed_conversion` generates an error
sydduckworth 50a95d1
Added tests for change to `warn_on_failed_conversion` behavior
sydduckworth ffeceba
Added `AsdfFutureWarning` as public export
sydduckworth 7a82d45
Expanded documentation for `tracked_property`
sydduckworth 99b7bee
Added tests for `tracked_property` and `is_set`
sydduckworth db9d1df
Updated config tests to cover `lazy_tree`
sydduckworth fab9e4f
Fixed implicit imports in `test_lazy_nodes.py`
sydduckworth 431f609
Added changelog entry
sydduckworth 0739710
Updated changelog
sydduckworth c557830
Added warning filter to config tests
sydduckworth b34949f
Moved `tracked_property` and `is_set` from `util` to `_helpers`
sydduckworth 893f187
Added warning to config documentation
sydduckworth 81e8d57
Replaced `is_set` with a simpler implementation
sydduckworth cb42bb1
Added another unit test for `is_set`
sydduckworth c8f2159
Moved tests for `is_set` from `test_util.py` to `test_helpers.py`
sydduckworth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import pytest | ||
|
|
||
| from asdf._helpers import _IsSet, is_set | ||
|
|
||
|
|
||
| class Tracked(_IsSet): | ||
| bar = None | ||
|
|
||
| def __init__(self): | ||
| # Intentionally not calling `super().__init__()` here to make sure `_IsSet` still works | ||
| self._value = 1 | ||
| self.baz = None | ||
|
|
||
| @property | ||
| def value(self): | ||
| return self._value | ||
|
|
||
| @value.setter | ||
| def value(self, value): | ||
| self._value = value | ||
|
|
||
|
|
||
| def test_is_set(): | ||
| x = Tracked() | ||
| y = Tracked() | ||
|
|
||
| def is_set_iter(obj): | ||
| yield from (is_set(obj, attr) for attr in ["value", "bar", "baz"]) | ||
|
|
||
| assert not any(is_set_iter(x)) | ||
|
|
||
| x.value = 2 | ||
| x.bar = 3 | ||
| x.baz = "foo" | ||
|
|
||
| assert all(is_set_iter(x)) | ||
| assert not any(is_set_iter(y)) | ||
|
|
||
|
|
||
| def test_is_set_attr_error(): | ||
| """Test that trying to access a non-existent property via `is_set` raises an `AttributeError`.""" | ||
| x = Tracked() | ||
| with pytest.raises(AttributeError): | ||
| is_set(x, "foo") | ||
|
|
||
|
|
||
| def test_is_set_type_error(): | ||
| with pytest.raises(TypeError): | ||
| # pyrefly: ignore [bad-argument-type] | ||
| is_set(object(), "foo") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| import pytest | ||
|
|
||
| import asdf | ||
| import asdf.tagged | ||
| from asdf import generic_io, util | ||
|
|
||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import enum | ||
| import importlib.util | ||
| import math | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| In a future release the default value for `asdf.config.AsdfConfig.warn_on_failed_conversion` will change from `False` to `True`. | ||
| Currently if ASDF raises an exception due to a conversion error it will now *also* emit a warning regarding the change in behavior. | ||
| To silence the warning you can either set ``warn_on_failed_conversion`` to `True` to opt into the new behavior | ||
| or to `False` to retain the old behavior. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.