You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you use a non-str argument to parse() for either path or base_path, parse fails. There are many valid reasons for using parse this way, notably using a pathlib.Path instead of a str. I think it would be better if both arguments accepted str | os.PathLike (or str | os.PathLike | None in the case of base_path) though one could make an argument that bytes should be valid as well. See os.PathLike.
If base_path is non-str, the error is:
AttributeError: 'PosixPath' object has no attribute '_Path__parts
I've fixed these in my vendored copy of this library and happy to push a PR. The issue happens because of these lines where isinstance checks whether the argument is a str:
You can see my relatively simple changes here. I also suggest adding type hints and am happy to include a PR for those if you'd like. It was not obvious to me without type hints that a non-str object (which contains a __str__() method) like pathlib.Path would fail.
If you use a non-str argument to
parse()
for eitherpath
orbase_path
,parse
fails. There are many valid reasons for using parse this way, notably using a pathlib.Path instead of a str. I think it would be better if both arguments acceptedstr | os.PathLike
(orstr | os.PathLike | None
in the case ofbase_path
) though one could make an argument thatbytes
should be valid as well. See os.PathLike.If
base_path
is non-str, the error is:And if
path
is non-str, the error is:The errors occur here:
gitignorefile/gitignorefile/__init__.py
Lines 268 to 272 in 822a7da
which calls:
gitignorefile/gitignorefile/__init__.py
Lines 159 to 161 in 822a7da
I've fixed these in my vendored copy of this library and happy to push a PR. The issue happens because of these lines where
isinstance
checks whether the argument is a str:gitignorefile/gitignorefile/__init__.py
Lines 262 to 271 in 822a7da
and
gitignorefile/gitignorefile/__init__.py
Lines 140 to 150 in 822a7da
Where the code assumes the argument is either a str or a
_Path
.The following test code demonstrates the error:
The text was updated successfully, but these errors were encountered: