-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Removed unused detection of site-packages directory #5874
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
Conversation
Remove use of deprecated module `distutils`
Co-authored-by: DaniΓ«l van Noord <[email protected]>
Pull Request Test Coverage Report for Build 1948863365
π - Coveralls |
I agree it's wise to put this in 2.14, but I suggest doing it right after 2.13 so it doesn't block contributors who have python 3.10 interpreters for pre-commit. (Pylint's pre-commit hook doesn't specify a version, correct? 3.8 is running on CI. I had to |
On mobile, so I can't check. But: does deprecated-module do anything with the python-version setting? If your python-version is set to 3.6, should we emit deprecated-module warnings for distutils? |
Good question. The deprecated checker uses a map keyed on python versions so that warnings won't be emitted for earlier versions, e.g. I suppose we should just specify python3.8 in the pre-commit config? language_version: python3.8 |
That was my question too. However it seems, the checker doesn't respect the It's definitely something worth exploring further IMO.
|
pylint/checkers/imports.py
Outdated
self._site_packages = self._compute_site_packages() | ||
|
||
@staticmethod | ||
def _compute_site_packages(): | ||
def _normalized_path(path): | ||
def _compute_site_packages() -> Set[str]: | ||
def _normalized_path(path: str) -> str: |
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.
Another question: Where is it still used? I wanted to check if STD_LIB_DIRS
is actual the correct replacement but couldn't find any code that uses self._site_packges
.
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.
pylint/checkers/imports.py
Outdated
) | ||
paths.add(libpython) | ||
return paths | ||
return {_normalized_path(path) for path in astroid.modutils.STD_LIB_DIRS} |
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.
return {_normalized_path(path) for path in astroid.modutils.STD_LIB_DIRS} | |
return {_normalized_path(path) for path in astroid.modutils.EXT_LIB_DIRS} |
If these should be the paths to the site-packages
dirs, it should be EXT_LIB_DIRS
instead.
See pylint-dev/astroid#1322
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.
Thanks, bad mistake. That was the PR I was looking at yesterday when I started down this path, and then I mistook the recent astroid changes for being relevant. π€
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.
Nice catch that it was unused ! In the end if we're just removing I think it can go in 2.13 ? (Btw we just reached 94% coverage, this kind of cleanup helps a lot to make the code base easier to maintain).
Thanks @jacobtylerwalls π¬ |
Type of Changes
Description
Remove use of deprecated moduledistutils
by relying on astroid's determination of the location of site packages. It seems error-prone to have two places for this logic.EDIT: remove unused functionality for determining the location of site-packages (unused since 9812c5a).