pylint is a useful tool to debug python in vscode, however, it keeps report errors on some unknown packages that are not available in my local environment, such as following codes

1
2
3
4
if local:
import a1
else:
import a2

pylint will keep report unable to import a2. After google around, I found a work around to fix this problem, just add following settings in user setting json file for vscode:

1
2
3
4
5
"python.linting.pylintArgs": [
"--errors-only",
"--generated-members=numpy.* ,torch.* ,cv2.* , cv.*",
"--ignored-modules=a2"
],

Then pylint will ignore a2 package errors.

Another bug of pylint is when using with torch or numpy, some functions cannot be found properly, such as torch.cat, above json can also suppress those errors.


Comments

2019-06-12