How to disable pylint 'Undefined variable' error for a specific variable in a file?

前端 未结 6 1498
慢半拍i
慢半拍i 2020-12-15 08:10

I am hosting IronPython inside a C# application and injecting an API for the host into the global scope.

I have just started to love syntastic for vim w

6条回答
  •  伪装坚强ぢ
    2020-12-15 08:10

    Actually, there is a way to disable pylint argues about the specific undefined variable(s) by specifying it in dummy-variables-rgx (or dummy-variables in the older pylint versions). dummy-variables contain _,dummy by default and overwritten with the user-specified values on pylint execution:

    $ pylint --dummy-variables-rgx='(_+[a-zA-Z0-9]*?$)|dummy|host_object'
    

    or for the older pylint versions:

    $ pylint --dummy-variables='_,dummy,host_object'
    

    Or in case of the pylint configuration for VSCode (User/Workspace Settings can be opened by pressing Ctrl + ,):

    "python.linting.pylintArgs": [
        "--dummy-variables-rgx='(_+[a-zA-Z0-9]*?$)|dummy|qdict'"
    ]
    

提交回复
热议问题