1

One of the modules I import into my python project triggers lots of warnings under Pychecker. Fixing up this external module isn't really an option, so I want to tell Pychecker to ignore it.

Does anyone know how to do this? I'm sure it's possible, and probably quite simple, but after trawling Google for a while I've not found any documentation or examples.

Thanks, Sam

Edit: I can't tag this with 'pychecker' unfortunately as that tag doesn't exist yet and my rep is too low to create.

Edit 2 Bonus extra question: does pychecker check ignored modules anyway, and just not print anything it finds? or do you get some speedup by ignoring some modules?

sam
  • 1,116
  • 2
  • 14
  • 19

3 Answers3

1

Per the docs,

If you want to suppress warnings on a module/function/class/method, you can define a suppressions dictionary in .pycheckrc. Examples of keys are: 'module', 'module.function', 'module.class', 'module.class.method', etc.etc.

IOW, in your .pycheckrc, if the troublesome module is named foobar, you'll have

suppressions = {'foobar': '...'}

where the ... means, all the suppress options you want. Use pychecker -h to get a list of all the options; I think 'limit=0' will do what you're asking for (show a max of 0 warnings for that module, i.e., none;-), but you may want to be a bit more selective (after all you only have to write this once and for all in .pycheckrc, not on every spot from which you're calling pychecker... which is the convenience of the pycheckrc approach!).

Alex Martelli
  • 854,459
  • 170
  • 1,222
  • 1,395
  • Thanks for your answer. Do you know if using this method means pychecker will ignore the imported modules, or will it check anyway and just suppress the warnings? – sam Sep 17 '10 at 15:43
  • @sam, I believe the check of a module will end once too many warnings have been reported (for it or altogether), but that's really an internal architecture issue which is not documented and might change on any source release, so if you really have to know how it behaves in a specific version I see no alternative to checking the sources (or trying with a dummy module full of warnings, etc). To check _only_ the modules you specifically list on the command line, of course, `--only` is a very popular command line option!-) – Alex Martelli Sep 17 '10 at 16:05
1

I've found another option - you can blacklist using the -b flag. Eg

python pychecker.py -b list,of,modules,to,ignore

I'm not sure, but I think this checks the imported modules anyway, but just doesn't print the warnings. It certainly doesn't seem any faster with the -b flag than without - though at least the warnings are gone :-)

sam
  • 1,116
  • 2
  • 14
  • 19
1

On the bonus extra question:

  • pychecker always imports the files you pass it, which causes it to import whatever those import. This is just like Python. This is a first pass in pychecker.
  • Then pychecker will actually go through the loaded modules, disassemble the code, and run through all the opcodes. This is a second pass.
  • In both cases, it tracks all warnings generated even by ignored modules. Then it filters out those warnings before showing them.

I am considering if it is worth it to change pychecker to not even look at blacklisted modules at all, or make it possible to only disassemble the one file (for integration in an editor for example).

Thomas Vander Stichele
  • 36,043
  • 14
  • 56
  • 60