openSUSE / libpathrs

C-friendly API to make path resolution safer on Linux.
GNU Lesser General Public License v3.0
83 stars 6 forks source link

python bindings: add type information and minor fixups #78

Closed cyphar closed 1 month ago

cyphar commented 1 month ago

This is just a first pass, trying to make the annotations make sense. We probably need to adjust some of them for packaging before the next release.

The type annotations for libpathrs.so should be sufficient but it's a bit unfortunate that ffi.NULL can't be listed as a possible return value (a-la None with Optional). This makes the typing for errorinfo a little dodgy, and the Error._fetch typing also is not entirely idiomatic (maybe we need to have an overload to indicate that only actual ErrorIds return an Error). It would be nice if we could do Literal[0..] but that syntax doesn't exist.

Signed-off-by: Aleksa Sarai cyphar@cyphar.com