OceanNetworksCanada / api-python-client

Provides easy access to ONC data in Python
https://oceannetworkscanada.github.io/api-python-client/
Apache License 2.0
10 stars 9 forks source link

outPath in ONC class constructor should accept both str and Path #12

Closed kan-fu closed 8 months ago

kan-fu commented 10 months ago

The idea occurred to me when I want to use a tmp_file fixture from pytest for outPath, but it only accepts str because it calls len to sanitize outPath. I have to convert it to str.

As illustrated in PEP519, the type of outPath should be typing.Union[str, bytes, os.PathLike]. For our use case, I think str | os.PathLike should be fine (with from __future__ import annotations of course).

Converting str to Path will eliminate the need for sanitizing. Both onc.py and _util.py need to be changed.