Just following up here on what I believe will be a solution, at least for my use case. As far as I’m aware, this solution is specific to Sphinx, the tool I’m using to generate html documentation from docstrings.
They key is to put the following at the top of your Sphinx conf.py file:
MOCK_MODULES = ['td', 'td.op']
for mod_name in MOCK_MODULES:
sys.modules[mod_name] = mock.Mock()
This makes a “mock” of the td module so that it can be imported without error by Sphinx. Source for this solution here. (you will need to install the mock library for the above to work btw: ‘pip install mock’)
This mock solution only works however if you import the td module in your code. Here’s the import code in one of my extensions that doesn’t make pylint or TD upset (as far as I’m aware):
from td import op, project, COMP, baseCOMP, ui # pylint:disable=import-error
The above is just an example of the imports I needed in one extension, with others usually only needing ‘op’ imported.
Hopefully this is helpful? Anyone got any better solutions?