textual
textual copied to clipboard
Can Textual widgets be made pylint-friendly?
Like many folk I'm a fan of using pylint to keep me honest when writing my Python code. However, given code like this:
from textual.widgets import Static, Header, Footer
I get complaints from pylint like this:
pipenv run pylint mandelplot
************* Module mandelplot
mandelplot:24:0: E0611: No name 'Static' in module 'textual.widgets' (no-name-in-module)
mandelplot:24:0: E0611: No name 'Header' in module 'textual.widgets' (no-name-in-module)
mandelplot:24:0: E0611: No name 'Footer' in module 'textual.widgets' (no-name-in-module)
------------------------------------------------------------------
Your code has been rated at 8.51/10 (previous run: 8.51/10, +0.00)
Presumably because of the lazy-loading mechanism in use.
Is there a good way of keeping pylint happy here?
Widgets could be imported under if typing.TYPE_CHECKING? Probably a hacky solution but it seems to make pylint happy.
if typing.TYPE_CHECKING:
from ..widget import Widget
from ._button import Button
from ._checkbox import Checkbox
from ._data_table import DataTable
from ._directory_tree import DirectoryTree
from ._footer import Footer
from ._header import Header
from ._placeholder import Placeholder
from ._pretty import Pretty
from ._static import Static
from ._input import Input
from ._text_log import TextLog
from ._tree_control import TreeControl
from ._welcome import Welcome
Good idea!
Did we solve your problem?
Glad we could help!