iustin / pyxattr

A python module for accessing filesystem Extended Attributes
https://pyxattr.k1024.org/
GNU Lesser General Public License v2.1
31 stars 14 forks source link

Fix example and maybe add typing #40

Open userappgate opened 1 year ago

userappgate commented 1 year ago

Hello,

I've started to use this project to annotate etag headers on downloaded files.

The example looks like it uses strings, but actually all strings get converted to bytes, so when reading it's all bytes… so initially it didn't match… because the type didn't match.

I understand that breaking API to just accept bytes and error out otherwise is maybe a bit much, but it'd be nice to have the examples use b'whatever' to reflect how it works.

Thanks

jabbalaci commented 9 months ago

The README should be updated to Python 3 IMO. And in Python 3 we get bytes, not strings. Example:

>>> import xattr
>>> xattr.listxattr("main.py")
[b'user.com.dropbox.attrs']
iustin commented 9 months ago

I don't know immediately whether one can add typing hints to C modules, or how easy/difficult it is, but the docstrings are easy to change.

The (temporary) output of the docs is here: https://pyxattr--46.org.readthedocs.build/46/module.html and looks about right, although there are a number of other Python 2-related comments to remove.

So I'll commit this docstring change first, and then look into the typing aspect.