-
-
Notifications
You must be signed in to change notification settings - Fork 933
Python 3.5 failing with AttributeError: module 'os' has no attribute 'PathLike' #1219
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
Comments
Thanks for reporting. That's interesting as I would have thought that our CI can pick this up. In any case, since python 3.5 is EOL and this PR exists I would probably prefer to cancel python 3.5 support rather than undoing the use of PathLike. In order to get this fixed, I could yank the offending version. However, first I would love to know why our CI seems to be fine with it. Thanks for your help |
We are using default in Azure Pipelines for python3, that seems to be 3.5 for us. We just patched to use python 3.6, so we are no longer impacted by 3.5. |
Good to hear. Since there is no further information on how to reproduce this issue, as well as no error messages for others to find, I think it's ok to close this issue until further information is presented to help understanding what's going on. Thanks for your understanding. |
FYI: I think this issue needs to be re-opened. It's still a problem with Python 3.6 too, just a different exception. (See below for details).
Doesn't appear to be the case:
This would seem like something unexpected to do in a patch release. Also, I find this to be broken for more than 3.5...
I think it's because of this in git/types.py: PathLike = Union[str, 'os.PathLike[str]'] For some reason that was written as a forward reference instead of a direct reference. I don't see any need for that here. This would cause evaluation of the type expression to be delayed until it's evaluated:
As you can see this fails immediately without using a forward reference (string version of the type expression) but waits to fail until evaluated by With Python 3.6 we get some improvement, as it's no longer complaining about
This exact error continues up to and including 3.8, it's only starting from 3.9 that both forms succeed:
The reason why none of this fails is because forward references will only get evaluated by tools that actually use the type annotations. And while I see a config file for mypy, which is such a tool, I cannot find any place where mypy actually gets called from CI... |
Summary:
Unfortunately I cannot find any documentation about the subscript form for that type, so I wouldn't know directly how to fix it for 3.6 onwards, let alone 3.5... I'm not even sure exactly what the intent of @Yobmod is with using the subscript form... I suggest poking him to look at this and fix it, and if that takes too long replacing the |
In in
os.PathLike does not exist in python 3.5.. So importing types should create this error in 3.5. |
Thanks a lot, @c4xuxo and @muggenhor. I think this issue neatly shows the outrageous level of incompetency I have reached maintaining this project which by now relies on blind trust in CI and luck 🤦♂️. Without digging into the reasons which to me are very clear, you may read this comment as a hint at my openness to pass on the torch of maintenance. In the mean time, things like these might keep happening unless I pace myself and prefer follow my very own rules over incorporating contributions. |
Hi all, Thanks for the fix of my mistake. I've been away on work, so not been able to get online until now. This solution is better than i would have done, which is just change os.pathlike to pathlib.Path (introduced 3.5) and see if mypy agreed. I'm hesitant to suggest adding mypy to the CI, as it would force all contributers to type everything or add type ignore comments when mypy cannot check it. Thanks again! |
Thanks for chiming in @Yobmod. The continuation of this conversation is here: #1223 (comment) |
According to https://github.com/softlayer/softlayer-python we have to stay Softlayer library <=5.7.2 since we are using python 3.5.2 This is to avoid AttributeError: module 'os' has no attribute 'PathLike' Details ---> gitpython-developers/GitPython#1219
This morning our builds started to fail as soon we moved to 3.1.15.
I seems that 3.1.15 makes use of os.PathLike that was introduced in python 3.6.
From README.md seems that Python 3.5 is still supported.
The text was updated successfully, but these errors were encountered: