-
-
Notifications
You must be signed in to change notification settings - Fork 273
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
Fix deprecated importlib methods #869
Fix deprecated importlib methods #869
Conversation
…at only zipimporter instances are returned.
astroid/interpreter/_import/spec.py
Outdated
@@ -285,7 +296,7 @@ def _precache_zipimporters(path=None): | |||
pic[entry_path] = zipimport.zipimporter(entry_path) | |||
except zipimport.ZipImportError: | |||
continue | |||
return pic | |||
return {key: value for key, value in pic.items() if isinstance(value, zipimport.zipimporter)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if that's as intended, but this simply filters out everything from pic
that is not a zipimport.zipimporter
class (i.e. the other types of importers). This may be related to the failing test too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GergelyKalmar it is exactly as intended. The goal is to have a container with only one type of objects. The failing tests (dealing with pypy) are not due to this PR.
@hippo91 It worked fine for me, I just added a few cosmetical suggestions. As this is supposed to be just a cache I think it should be fine to potentially throw out things which are not of zipimporter type, but I must add too that I'm not super familiar with the inner workings of astroid. |
Taking into account @GergelyKalmar suggestion Co-authored-by: Gergely Kalmár <gergely.kalmar@logikal.jp>
Taking into account @GergelyKalmar suggestion Co-authored-by: Gergely Kalmár <gergely.kalmar@logikal.jp>
Taking into account @GergelyKalmar suggestion Co-authored-by: Gergely Kalmár <gergely.kalmar@logikal.jp>
Taking into account @GergelyKalmar suggestion Co-authored-by: Gergely Kalmár <gergely.kalmar@logikal.jp>
@GergelyKalmar thanks for your wise suggestions! |
@hippo91 Awesome! Thank you for the help with this quite tricky issue. Feel free to merge & release! |
Steps
Description
This PR is a variant from #811 . Instead of having different types of objects inside the
pic.items()
collection returned by the_precache_zipimporters
function, the return value of this last one is filled only withzipimporter
instances.Thus the warning dealing with
find_spec/find_module
is no more present becausezipimporter
object have onlyfind_module
method.For more details please read the conversation of #811.
Type of Changes
Related issue
Closes #703