Deltares / xugrid

Xarray and unstructured grids
https://deltares.github.io/xugrid/
MIT License
64 stars 8 forks source link

Use of `pathlib.Path` as context manager is deprecated #244

Closed savente93 closed 3 months ago

savente93 commented 4 months ago

While doing some work on hydromt to make it warning free, this error bubbled up from xugrid:

.pixi/envs/full-py311/lib/python3.11/site-packages/xugrid/data/sample_data.py:16: in <module>
    with importlib.resources.files("xugrid.data") as path:
.pixi/envs/full-py311/lib/python3.11/pathlib.py:891: in __enter__
    warnings.warn("pathlib.Path.__enter__() is deprecated and scheduled "
E   DeprecationWarning: pathlib.Path.__enter__() is deprecated and scheduled for removal in Python 3.13; Path objects as a context manager is a no-op

The code in question is this: https://github.com/Deltares/xugrid/blob/1390aeb3e0a49a1989e845f7f238c84827708bee/xugrid/data/sample_data.py#L16

The use of pathlib.Path is deprecated and should not be used. We can just assign the path directly, and clean it up after if necessary. I'll be happy to open a PR for this if anyone is interested. Thanks!

Huite commented 4 months ago

Indeed, I would greatly appreciate a PR!

savente93 commented 4 months ago

Nice! I'm quite busy this week but I hope that I"ll get around to it next week. It should be a very small one through.