I am trying to work on my current python program, very aware of pylint warnings, so although I understand that I can just turn off the warning, I want to be sure that there was no more desirable solution before.
My current section of code is my registration code. I have an init() function that installs handlers and attaches them to the root log, and the set_console_level(level) function sets the level at which console messages are reported (DEBUG, INFO, etc.):
_CONSOLE_OUT = NONE def init(): """Set up the error handlers for the root logger""" console_out = logging.StreamHandler() console_out.setLevel(logging.INFO) #Show info messages for now #... logging.root.addHandler(console_out) global _CONSOLE_OUT _CONSOLE_OUT = console_out #Rest of function sets up more handlers similarly init() def set_console_level(level): """Change the level at which console messages are printed""" assert __CONSOLE_OUT is not None #Set in init _CONSOLE_OUT.setLevel(level)
As far as I can tell from my reading, this is a way to do it. The global _CONSOLE_OUT required to write to the module level variable. However, when I run pylint in this file, I get a warning W: 15,4:init: Using the global statement . Is there any way to avoid this warning? Best way to approach this problem?
(Please do not say global _CONSOLE_OUT #pylint: disable=W**** without specification)
source share