-
-
Notifications
You must be signed in to change notification settings - Fork 932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
git.types.PathLike is partially unknown for Pylance/mypy #1473
Comments
Thanks for bringing this up. I think for correctness, the type should be |
Hi,
I'll try to make a PR by tomorrow to fix this issue, I won't be available
for the next few days after then so hopefully you need anything else from
me!
…On Wed, Jul 27, 2022, 02:17 Sebastian Thiel ***@***.***> wrote:
Thanks for bringing this up. I think for correctness, the type should be
os.PathLike[str|bytes] if this doesn't pose a problem. A PR for that
would definitely be welcome, thanks for offering.
—
Reply to this email directly, view it on GitHub
<#1473 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOSDPZZQOSIQFLKRLFBSPA3VWB527ANCNFSM54UGC3MA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
So, after digging thing a bit deeper, my error I had in #1474 was because I was trying to convert My wonder here is why, actually, should I add bytes? |
Thanks for the follow-up. Accepting that, then not adding bytes would be the way to go and leaving the PR as is, right? If so, please feel free to remove |
Hello everyone,
I am using GitPython in my project and I use Pylance/mypy with the strict type checking settings. This setting is pretty important for my project's sanity.
As I've been using methods from GitPython that make uses of paths, I've been getting the following errors:

As you can notice, what raises this error is
PathLike[Unknown]
, defined ingit.types.PathLike
. (Source file & lines)After further investigation, I've found out that this is because

os.PathLike
is considered as a generic class (Liketyping.List
,typing.Dict
and so on)The fix is fairly simple, as it is to simply allow
str
forPathLike
, which gives this result:os.PathLike[str]
(awesome! This issue's no longer a thing with this fix!)
There has some discussion about the same situation on this StackOverflow page: https://stackoverflow.com/a/69680089/13720113
I can make a PR for fixing this (Of course, with some testing, since there is Python version checks), as long as this issue is approved.
Thank you, hoping this issue get sorted soon!
The text was updated successfully, but these errors were encountered: