Skip to content

Conversation

@wendtalexander
Copy link
Contributor

Currently, I am utilizing the pathlib module for all file system interactions. In my opinion, Nix should also adopt this approach. Instead of requiring manual conversion of paths to the appropriate encoding, Nix should accept path objects directly.

I have attempted to implement this change for you and provided a test demonstrating how to open a Nix file using a pathlib.Path object.

Furthermore, I have removed the encoding check for UTF-8 because h5py can handle emojis in path-like objects. However, I acknowledge that this change may impact backwards compatibility.

As of h5py 2.0.0, Unicode is supported for file names and objects in the file. When object names are read, they are returned as Unicode by default. For more information, please refer to the h5pyFAQ at h5pyFAQ.

@coveralls
Copy link

coveralls commented Mar 1, 2025

Coverage Status

coverage: 78.615% (+0.04%) from 78.571%
when pulling 6da4a2f on wendtalexander:pathlib
into 80d2df2 on G-Node:master.

@jgrewe
Copy link
Member

jgrewe commented Mar 2, 2025

thanks @wendtalexander. I guess I would like to have the tests included into the existing test_file.py instead of creating a new test case.
Not sure about the dependency of h5py > 2.0, we would need to change the requirements accordingly. (any thoughts @achilleas-k?)

@achilleas-k
Copy link
Member

Not sure about the dependency of h5py > 2.0, we would need to change the requirements accordingly. (any thoughts @achilleas-k?)

Depends what distro versions we're still targeting and if they have new enough h5py versions, I suppose. Is nixpy still available in any distribution repositories?

@jgrewe
Copy link
Member

jgrewe commented Mar 24, 2025

@achilleas-k I browsed a bit and having a dependency > 2.0 does not seem to be a big deal even in Debian buster the version is 2.8.something. I guess it should not be a problem.

@achilleas-k
Copy link
Member

Sounds like it should be fine then!

nixio/file.py Outdated

import pathlib
import gc
from typing import Union
Copy link
Member

Choose a reason for hiding this comment

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

A bit nit-picky, but would you mind to organize the imports a bit differently, i.e. the from xyz style import should be below the simple import xyz statements.

Copy link
Member

Choose a reason for hiding this comment

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

I like the way isort handles import ordering. We could add that as a linter and enforce it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah that would be nice to enforce this!

@jgrewe jgrewe merged commit 5e5ec01 into G-Node:master Mar 29, 2025
21 checks passed
@wendtalexander wendtalexander deleted the pathlib branch April 17, 2025 09:11
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

Successfully merging this pull request may close these issues.

4 participants