Skip to content

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

Merged
merged 4 commits into from
Mar 8, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions pylint/checkers/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@
import collections
import copy
import os
import sys
from distutils import sysconfig
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Set, Tuple, Union

import astroid
Expand Down Expand Up @@ -448,25 +446,7 @@ def _compute_site_packages():
def _normalized_path(path):
return os.path.normcase(os.path.abspath(path))

paths = set()
real_prefix = getattr(sys, "real_prefix", None)
for prefix in filter(None, (real_prefix, sys.prefix)):
path = sysconfig.get_python_lib(prefix=prefix)
path = _normalized_path(path)
paths.add(path)

# Handle Debian's derivatives /usr/local.
if os.path.isfile("/etc/debian_version"):
for prefix in filter(None, (real_prefix, sys.prefix)):
libpython = os.path.join(
prefix,
"local",
"lib",
"python" + sysconfig.get_python_version(),
"dist-packages",
)
paths.add(libpython)
return paths
return {_normalized_path(path) for path in astroid.modutils.STD_LIB_DIRS}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Member Author

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


def open(self):
"""Called before visiting project (i.e set of modules)."""
Expand Down