I have the following at the top of my file/module which says how various types are defined (sort of like a declaration in a C file):
Env = dict # The Interpreter environment is a map of {key: value}
And then below in the actual meat of the code I redefine Env
like so:
class Env(dict):
"An environment dict, containing the parent Env (or None) where created."
def __init__(self, parent=None):
self.parent = parent
# etc.
Pylint gives me the following warning:
function-redefined: class already defined line 16
I understand why it is giving this, but it is intentional in the above case. What would be the suggested way to deal with this? Doing something like the following seems to be the most expedient way (but then I find my files are just littered with all these comments every other line if I apply this "let's-dismiss-this-one-here" philosophy), but what would someone suggest in this particular case?
class Env(dict): # pylint: disable=function-redefinition
Additionally, what is the name for doing the # pylint:
thing called? (Comment/Annotation/Pragma/?)
Additionally, here is a useful thread about type redefinitions in mypy
: https://github.com/python/mypy/issues/1191.