explosion / srsly

🦉 Modern high-performance serialization utilities for Python (JSON, MessagePack, Pickle)
MIT License
432 stars 31 forks source link

Fix path coercion for pathlib-like interfaces (Pathy) #106

Closed justindujardin closed 9 months ago

justindujardin commented 9 months ago

Pathy inherited from pathlib.Path, so this always worked for saving spaCy models, but a new Pathy version that supports Python 3.12 will not inherit from pathlib.Path so this check fails and model saving goes with it.

Someone pointed out that the spaCy contributing doc specifies how things should work.

Code that interacts with the file-system should accept objects that follow the pathlib.Path API, without assuming that the object inherits from pathlib.Path. If the function is user-facing and takes a path as an argument, it should check whether the path is provided as a string. Strings should be converted to pathlib.Path objects.

I don't know if that extends to srsly, but I would think so.

There's more context on the Pathy 3.12 issue: https://github.com/justindujardin/pathy/issues/106#issuecomment-1885500685