UPDATE: I fixed my incorrect use of the term "PYQA" and changed it to the proper "NOQA".
We're running under linux and are using python 3.7.
We have a large code base that has been in use for years in which we have recently starting using pyflakes to help with code validation. It is working well in most cases. However ...
A subset of our python modules are dynamically loaded by reading the python file, compiling it to get a code object, and then exec-ing that code object. This has always been working well for us in general, but it is causing problems now with our pyflakes tests.
The following is a very simplfied example of one of these dynamically loadable modules. Suppose it is named dynmod.py ...
# Note that `GenericClass` and `utility_function()` are already
# defined within the python module which dynamically loads this
# `dynmod.py` module.
class LocalClass(GenericClass):
def __init__(self, a, b, c):
self.extravar0 = 0
self.extravar1 = 1
super().__init__(a, b, c)
def extramethod(self):
utility_function(self.extravar0, self.extravar1)
The problem is that when I run pyflakes against dynmod.py, it tags GenericClass and utility_function as undefined name. I understand that this is correct pyflakes behavior, since pyflakes doesn't see any definition for these items.
However, I'm looking for a way to override the errors for these particular kinds of issues without using NOQA tags on each and every line that contains one of these objects or variables which are defined in the loader module. This is because there are several dozen of these dynamically loaded modules and several dozen objects from the loader module that are referenced from the python modules, and some of these dynamically loaded modules are very large and have lots of references to those items that are defined in the loader module.
And we still want pyflakes to catch other validly undefined variable references that might appear in these dynamically loaded modules.
Instead of disabling pyflakes validation line by line via NOQA tags, is there a way to tell it something like the following? "Please do not flag the following items as 'undefined': 'GenericClass', 'utility_function'" ?
If not, can anyone suggest another method for identifying undefined variables in dynamically loaded python modules which ignores errors for variables that are defined in the module which loads the dynamic module?
And to be clear, we don't want to disable all undefined name errors ... only those which reference items that are indeed defined in the loading module.
Thank you very much in advance.