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 with pylint
for checking my scripts. But I am getting annoyed by all the [E0602, method_name] Undefined variable 'variable_name'
error messages for the injected variables.
I am aware of using # pylint: disable=E0602
to disable this error message, but I'd prefer not to cripple a really useful feature just for some specific variable names.
How do you deal with this?
Currently, I am doing this at the top of my script:
try:
host_object = getattr(__builtins__, 'host_object')
except AttributeError:
pass # oops, run this script inside the host application!!
What I would really like to do is this:
# pylint: declare=host_object, other_stuff
You can add your variables to the 'additional-builtins' option so pylint will consider them as defined.
This has to be done in a rc file, it can't be done inlined in the code.
Disabling E0602 in the code:
# make pylint think that it knows about 'injected_var' variable
injected_var = injected_var # pylint:disable=invalid-name,used-before-assignment
Obviously, that needs to be done once per module, all occurrences of injected_var
after this line would be legal for pylint.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With