Skip to content
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

deprecate encoding setters #7708

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

jhamman
Copy link
Member

@jhamman jhamman commented Apr 3, 2023

  • Toward propagation of encoding #6323
  • Tests added
  • User visible changes (including notable bug fixes) are documented in whats-new.rst
  • New functions/methods are listed in api.rst

Sorry, something went wrong.

Verified

This commit was signed with the committer’s verified signature.
jhamman Joe Hamman
fix bad merge
@jhamman jhamman force-pushed the dep/encoding-setter branch from 6cfd646 to 988dfcf Compare April 3, 2023 03:10

Verified

This commit was signed with the committer’s verified signature.
jhamman Joe Hamman
til - property setters need to directly follow the property def
@jhamman jhamman marked this pull request as ready for review April 3, 2023 14:53
Copy link
Member Author

@jhamman jhamman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ready for a quick look from folks. Tests are passing and we're not leaking FutureWarnings on internal calls anymore.

Something I could use some feedback on is how we want to handle encoding.__setitem__ warnings. As implmented now, this warns:

ds.encoding = {"unlimited_dims": {"x"}}

but this does not:

ds["unlimited_dims"] = {"x"}

To issue a warning from the latter, we need to override the __setitem__ on the _encoding attribute which is currently a vanilla dict. I'm slightly concerned about going down this path but I think it is possible if we are willing to change the type of the encoding attribute.

@@ -512,6 +512,7 @@ def test_roundtrip_string_data(self) -> None:
with self.roundtrip(expected) as actual:
assert_identical(expected, actual)

@pytest.mark.filterwarnings("ignore:Setting encoding directly.*:FutureWarning")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've explicitly marked all tests that use the encoding setter with this filter. When we remove the setter, we'll need to come back through and rework these tests.

Comment on lines 876 to +883
@encoding.setter
def encoding(self, value: Mapping[Any, Any]) -> None:
# deprecated (variable setter will warn)
self.variable.encoding = dict(value)

def _set_encoding_internal(self, value: Mapping[Any, Any]) -> None:
"""temporary method to set encoding without issuing a FutureWarning"""
self.variable._set_encoding_internal(value)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future when @encoding.setter is gone, we will likely still wan/need a way to insert encoding attributes onto objects (coding and backends currently require this). I'm open to new names but this method is intended to be that code path.

Verified

This commit was signed with the committer’s verified signature.
jhamman Joe Hamman
@jhamman jhamman requested review from keewis and dcherian April 3, 2023 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant