PyLint in vscode reports error Unable to import solution

When importing py files in other folders, even if the specified path is added to the code, because Pylint cannot detect the file, an error message of Unable to import 'xxx' will be given

You need to add a .pylintrc file to the project directory to specify the directory where the file to be referenced is located

# .pylintrc file for custom configuration for pllint

[MASTER]
# XXX should be replaced with the folder you specified e.g. (./custom_lib)
init-hook='base_dir="XXX"; import sys,os,re; _re=re.search(r".+\/" + base_dir, os.getcwd()); project_dir = _re.group() if _re else os.path.join(os.getcwd(), base_dir); sys.path.append(project_dir)'

[MESSAGES CONTROL]
# Find available symbolic names in:
# https://docs.pylint.org/features.html
disable=locally-disabled,trailing-whitespace,fixme,missing-docstring,protected-access,invalid-name,super-init-not-called,star-args,no-self-argument,inherit-non-class,no-method-argument,no-self-use,unused-argument,too-many-return-statements,too-many-branches,too-many-function-args,too-many-instance-attributes,too-many-locals,bad-continuation,unnecessary-lambda,redefined-variable-type,global-statement,line-too-long,mixed-indentation,bad-whitespace,missing-final-newline

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324512227&siteId=291194637
Recommended