HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Users/fred/anaconda3/Lib/site-packages/pylsp/plugins/preload_imports.py
# Copyright 2017-2020 Palantir Technologies, Inc.
# Copyright 2021- Python Language Server Contributors.

import logging

from pylsp import hookimpl

log = logging.getLogger(__name__)

MODULES = [
    "OpenGL",
    "PIL",
    "array",
    "audioop",
    "binascii",
    "cPickle",
    "cStringIO",
    "cmath",
    "collections",
    "datetime",
    "errno",
    "exceptions",
    "gc",
    "imageop",
    "imp",
    "itertools",
    "marshal",
    "math",
    "matplotlib",
    "mmap",
    "mpmath",
    "msvcrt",
    "networkx",
    "nose",
    "nt",
    "numpy",
    "operator",
    "os",
    "os.path",
    "pandas",
    "parser",
    "rgbimg",
    "scipy",
    "signal",
    "skimage",
    "sklearn",
    "statsmodels",
    "strop",
    "sympy",
    "sys",
    "thread",
    "time",
    "wx",
    "xxsubtype",
    "zipimport",
    "zlib",
]


@hookimpl
def pylsp_settings():
    # Setup default modules to preload, and rope extension modules
    return {
        "plugins": {"preload": {"modules": MODULES}},
        "rope": {"extensionModules": MODULES},
    }


@hookimpl
def pylsp_initialize(config):
    for mod_name in config.plugin_settings("preload").get("modules", []):
        try:
            __import__(mod_name)
            log.debug("Preloaded module %s", mod_name)
        except Exception:
            # Catch any exception since not only ImportError can be raised here
            # For example, old versions of NumPy can cause a ValueError.
            # See spyder-ide/spyder#13985
            pass