Skip to content
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

Merged
merged 10 commits into from
Dec 30, 2020

Conversation

hippo91
Copy link
Contributor

@hippo91 hippo91 commented Dec 24, 2020

Steps

  • For new features or bug fixes, add a ChangeLog entry describing what your PR does.
  • Write a good description on what the PR does.

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 with zipimporter instances.
Thus the warning dealing with find_spec/find_module is no more present because zipimporter object have only find_module method.
For more details please read the conversation of #811.

Type of Changes

Type
🐛 Bug fix

Related issue

Closes #703

@hippo91 hippo91 mentioned this pull request Dec 24, 2020
2 tasks
@@ -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)}
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@GergelyKalmar
Copy link
Contributor

@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.

hippo91 and others added 6 commits December 24, 2020 15:29
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>
@hippo91
Copy link
Contributor Author

hippo91 commented Dec 29, 2020

@GergelyKalmar thanks for your wise suggestions!

@GergelyKalmar
Copy link
Contributor

@hippo91 Awesome! Thank you for the help with this quite tricky issue. Feel free to merge & release!

@hippo91 hippo91 merged commit a8bde99 into pylint-dev:master Dec 30, 2020
@hippo91 hippo91 deleted the fix_deprecated_importlib_methods branch December 30, 2020 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ImportWarning due to usage of deprecated method
2 participants