Pregunta

I am developing Python scripts which run inside a Jython interpreter. This interpreter sets certain global variables, which I use inside the script.

Pylint of course does not know these variables, so it reports errors all over the place.

Is there a way of making pylint aware that there are certain variables defined outside of its scope?

Alternatively, is there a way that I can define the unknown variables to pylint?

I tried something like

if not globals().has_key('SOME_EXTERNAL_GLOBAL'):
    globals()['SOME_EXTERNAL_GLOBAL'] = None

But that did not help (pylint seems to ignore black magic done to globals()).

¿Fue útil?

Solución

You have several options:

additional-builtins:

List of additional names supposed to be defined in builtins. Remember that you should avoid to define new builtins when possible.

  • add # pylint: disable=E0602 comment on top of the file to disable undefined-variable check in the file
  • add # pylint: disable=E0602 comment in the code where the variable is used
  • run pylint with --disable-msg=E0602 option

Also see:

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top