1

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()).

Jonas
  • 598
  • 5
  • 6

1 Answers1

4

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:

Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • Thanks! It seems like all of these have to be done in the rc file (rather than inline in the code)... – Jonas Sep 06 '13 at 11:37
  • 1
    There's also [`good-names`](http://pylint.pycqa.org/en/latest/technical_reference/features.html#basic-checker-options) – Tobias Kienzler Feb 18 '20 at 08:28