Search code examples
pythonvisual-studio-codearcpy

Ignore error "Module 'arcpy.da' has no 'SearchCursor' member" in VS Code


I develop many scripts with arcpy in VS Code, and every time I use a Cursor, VSCode thinks it is an error:

enter image description here

It does not affect the scripts performance, but, is there any way to make VS Code ignore this particular kind of (what it interpret as) errors?

Just so that they are not displayed in the problems panel.


Solution

  • Due to the recurrence of the problem, please allow me to take the module "cv2" as an example.

    We can add the following settings in "settings.json" to ignore the warnings of the module "cv2" and not ignore the problems from other modules. (Since pylint information provides suggestions for us to edit code, it is recommended that you make sure that the code can be executed before closing its information.)

    "python.linting.pylintArgs": ["--generated-members=cv2.*"],
    

    before:

    enter image description here

    after:

    enter image description here