textual icon indicating copy to clipboard operation
textual copied to clipboard

Can Textual widgets be made pylint-friendly?

Open davep opened this issue 3 years ago • 2 comments

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?

davep avatar Nov 03 '22 22:11 davep

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

aaronst avatar Nov 05 '22 19:11 aaronst

Good idea!

willmcgugan avatar Nov 05 '22 19:11 willmcgugan

Did we solve your problem?

Glad we could help!

github-actions[bot] avatar Nov 07 '22 16:11 github-actions[bot]