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

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

Closed
savente93 opened this issue May 24, 2024 · 2 comments
Closed

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

savente93 opened this issue May 24, 2024 · 2 comments

Comments

@savente93
Copy link
Contributor

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:

with importlib.resources.files("xugrid.data") as path:

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
Copy link
Collaborator

Huite commented May 26, 2024

Indeed, I would greatly appreciate a PR!

@savente93
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants