The following issues were found
src/textual/reactive.py
13 issues
Line: 16
Column: 1
TYPE_CHECKING,
)
from . import log
from . import events
from ._callback import count_parameters, invoke
from ._types import MessageTarget
Reported by Pylint.
Line: 17
Column: 1
)
from . import log
from . import events
from ._callback import count_parameters, invoke
from ._types import MessageTarget
if TYPE_CHECKING:
Reported by Pylint.
Line: 19
Column: 1
from . import log
from . import events
from ._callback import count_parameters, invoke
from ._types import MessageTarget
if TYPE_CHECKING:
from .app import App
from .widget import Widget
Reported by Pylint.
Line: 20
Column: 1
from . import events
from ._callback import count_parameters, invoke
from ._types import MessageTarget
if TYPE_CHECKING:
from .app import App
from .widget import Widget
Reported by Pylint.
Line: 23
Column: 5
from ._types import MessageTarget
if TYPE_CHECKING:
from .app import App
from .widget import Widget
Reactable = Union[Widget, App]
Reported by Pylint.
Line: 24
Column: 5
if TYPE_CHECKING:
from .app import App
from .widget import Widget
Reactable = Union[Widget, App]
ReactiveType = TypeVar("ReactiveType")
Reported by Pylint.
Line: 16
Column: 1
TYPE_CHECKING,
)
from . import log
from . import events
from ._callback import count_parameters, invoke
from ._types import MessageTarget
Reported by Pylint.
Line: 57
Column: 9
setattr(owner, "__computes", computes)
computes.append(name)
self.name = name
self.internal_name = f"__{name}"
setattr(owner, self.internal_name, self._default)
def __get__(self, obj: Reactable, obj_type: type[object]) -> ReactiveType:
return getattr(obj, self.internal_name)
Reported by Pylint.
Line: 58
Column: 9
computes.append(name)
self.name = name
self.internal_name = f"__{name}"
setattr(owner, self.internal_name, self._default)
def __get__(self, obj: Reactable, obj_type: type[object]) -> ReactiveType:
return getattr(obj, self.internal_name)
Reported by Pylint.
Line: 1
Column: 1
from __future__ import annotations
from inspect import isawaitable
from functools import partial
from typing import (
Any,
Awaitable,
Callable,
Generic,
Reported by Pylint.
src/textual/_timer.py
13 issues
Line: 8
Column: 1
from time import monotonic
from typing import Awaitable, Callable, Union
from rich.repr import Result, rich_repr
from . import events
from ._types import MessageTarget
TimerCallback = Union[Callable[[], Awaitable[None]], Callable[[], None]]
Reported by Pylint.
Line: 10
Column: 1
from rich.repr import Result, rich_repr
from . import events
from ._types import MessageTarget
TimerCallback = Union[Callable[[], Awaitable[None]], Callable[[], None]]
Reported by Pylint.
Line: 11
Column: 1
from rich.repr import Result, rich_repr
from . import events
from ._types import MessageTarget
TimerCallback = Union[Callable[[], Awaitable[None]], Callable[[], None]]
class EventTargetGone(Exception):
Reported by Pylint.
Line: 4
Column: 1
from __future__ import annotations
import weakref
from asyncio import CancelledError, Event, TimeoutError, wait_for
from time import monotonic
from typing import Awaitable, Callable, Union
from rich.repr import Result, rich_repr
Reported by Pylint.
Line: 1
Column: 1
from __future__ import annotations
import weakref
from asyncio import CancelledError, Event, TimeoutError, wait_for
from time import monotonic
from typing import Awaitable, Callable, Union
from rich.repr import Result, rich_repr
Reported by Pylint.
Line: 16
Column: 1
TimerCallback = Union[Callable[[], Awaitable[None]], Callable[[], None]]
class EventTargetGone(Exception):
pass
@rich_repr
class Timer:
Reported by Pylint.
Line: 21
Column: 1
@rich_repr
class Timer:
_timer_count: int = 1
def __init__(
self,
event_target: MessageTarget,
Reported by Pylint.
Line: 21
Column: 1
@rich_repr
class Timer:
_timer_count: int = 1
def __init__(
self,
event_target: MessageTarget,
Reported by Pylint.
Line: 56
Column: 5
yield "repeat", self._repeat, None
@property
def target(self) -> MessageTarget:
target = self._target()
if target is None:
raise EventTargetGone()
return target
Reported by Pylint.
Line: 62
Column: 5
raise EventTargetGone()
return target
def stop(self) -> None:
self._active.set()
self._stop_event.set()
def pause(self) -> None:
self._active.clear()
Reported by Pylint.
src/textual/_types.py
12 issues
Line: 3
Column: 1
import sys
from typing import Awaitable, Callable, List, Optional, TYPE_CHECKING
from rich.segment import Segment
if sys.version_info >= (3, 8):
from typing import Protocol
else:
from typing_extensions import Protocol
Reported by Pylint.
Line: 8
Column: 5
if sys.version_info >= (3, 8):
from typing import Protocol
else:
from typing_extensions import Protocol
if TYPE_CHECKING:
from .events import Event
from .message import Message
Reported by Pylint.
Line: 12
Column: 5
if TYPE_CHECKING:
from .events import Event
from .message import Message
Callback = Callable[[], None]
# IntervalID = int
Reported by Pylint.
Line: 13
Column: 5
if TYPE_CHECKING:
from .events import Event
from .message import Message
Callback = Callable[[], None]
# IntervalID = int
Reported by Pylint.
Line: 2
Column: 1
import sys
from typing import Awaitable, Callable, List, Optional, TYPE_CHECKING
from rich.segment import Segment
if sys.version_info >= (3, 8):
from typing import Protocol
else:
from typing_extensions import Protocol
Reported by Pylint.
Line: 1
Column: 1
import sys
from typing import Awaitable, Callable, List, Optional, TYPE_CHECKING
from rich.segment import Segment
if sys.version_info >= (3, 8):
from typing import Protocol
else:
from typing_extensions import Protocol
Reported by Pylint.
Line: 19
Column: 1
# IntervalID = int
class MessageTarget(Protocol):
async def post_message(self, message: "Message") -> bool:
...
def post_message_no_wait(self, message: "Message") -> bool:
...
Reported by Pylint.
Line: 20
Column: 5
class MessageTarget(Protocol):
async def post_message(self, message: "Message") -> bool:
...
def post_message_no_wait(self, message: "Message") -> bool:
...
Reported by Pylint.
Line: 23
Column: 5
async def post_message(self, message: "Message") -> bool:
...
def post_message_no_wait(self, message: "Message") -> bool:
...
class EventTarget(Protocol):
async def post_message(self, message: "Message") -> bool:
Reported by Pylint.
Line: 27
Column: 1
...
class EventTarget(Protocol):
async def post_message(self, message: "Message") -> bool:
...
def post_message_no_wait(self, message: "Message") -> bool:
...
Reported by Pylint.
src/textual/screen_update.py
12 issues
Line: 5
Column: 1
from typing import Iterable
from rich.console import Console, RenderableType
from rich.control import Control
from rich.segment import Segment, Segments
from .geometry import Offset
from ._loop import loop_last
Reported by Pylint.
Line: 6
Column: 1
from typing import Iterable
from rich.console import Console, RenderableType
from rich.control import Control
from rich.segment import Segment, Segments
from .geometry import Offset
from ._loop import loop_last
Reported by Pylint.
Line: 7
Column: 1
from rich.console import Console, RenderableType
from rich.control import Control
from rich.segment import Segment, Segments
from .geometry import Offset
from ._loop import loop_last
Reported by Pylint.
Line: 9
Column: 1
from rich.control import Control
from rich.segment import Segment, Segments
from .geometry import Offset
from ._loop import loop_last
class ScreenUpdate:
def __init__(
Reported by Pylint.
Line: 10
Column: 1
from rich.segment import Segment, Segments
from .geometry import Offset
from ._loop import loop_last
class ScreenUpdate:
def __init__(
self, console: Console, renderable: RenderableType, width: int, height: int
Reported by Pylint.
Line: 1
Column: 1
from __future__ import annotations
from typing import Iterable
from rich.console import Console, RenderableType
from rich.control import Control
from rich.segment import Segment, Segments
from .geometry import Offset
Reported by Pylint.
Line: 13
Column: 1
from ._loop import loop_last
class ScreenUpdate:
def __init__(
self, console: Console, renderable: RenderableType, width: int, height: int
) -> None:
self.lines = console.render_lines(
Reported by Pylint.
Line: 23
Column: 5
)
self.offset = Offset(0, 0)
def render(self, x: int, y: int) -> Iterable[Segment]:
move_to = Control.move_to
new_line = Segment.line()
for last, (offset_y, line) in loop_last(enumerate(self.lines, y)):
yield move_to(x, offset_y).segment
yield from line
Reported by Pylint.
Line: 23
Column: 5
)
self.offset = Offset(0, 0)
def render(self, x: int, y: int) -> Iterable[Segment]:
move_to = Control.move_to
new_line = Segment.line()
for last, (offset_y, line) in loop_last(enumerate(self.lines, y)):
yield move_to(x, offset_y).segment
yield from line
Reported by Pylint.
Line: 23
Column: 5
)
self.offset = Offset(0, 0)
def render(self, x: int, y: int) -> Iterable[Segment]:
move_to = Control.move_to
new_line = Segment.line()
for last, (offset_y, line) in loop_last(enumerate(self.lines, y)):
yield move_to(x, offset_y).segment
yield from line
Reported by Pylint.
src/textual/messages.py
12 issues
Line: 4
Column: 1
from __future__ import annotations
from typing import TYPE_CHECKING
import rich.repr
from .message import Message
if TYPE_CHECKING:
Reported by Pylint.
Line: 6
Column: 1
import rich.repr
from .message import Message
if TYPE_CHECKING:
from .message_pump import MessagePump
from .widget import Widget
Reported by Pylint.
Line: 10
Column: 5
if TYPE_CHECKING:
from .message_pump import MessagePump
from .widget import Widget
@rich.repr.auto
class UpdateMessage(Message, verbosity=3):
Reported by Pylint.
Line: 11
Column: 5
if TYPE_CHECKING:
from .message_pump import MessagePump
from .widget import Widget
@rich.repr.auto
class UpdateMessage(Message, verbosity=3):
def __init__(self, sender: MessagePump, widget: Widget, layout: bool = False):
Reported by Pylint.
Line: 1
Column: 1
from __future__ import annotations
from typing import TYPE_CHECKING
import rich.repr
from .message import Message
if TYPE_CHECKING:
Reported by Pylint.
Line: 15
Column: 1
@rich.repr.auto
class UpdateMessage(Message, verbosity=3):
def __init__(self, sender: MessagePump, widget: Widget, layout: bool = False):
super().__init__(sender)
self.widget = widget
self.layout = layout
Reported by Pylint.
Line: 15
Column: 1
@rich.repr.auto
class UpdateMessage(Message, verbosity=3):
def __init__(self, sender: MessagePump, widget: Widget, layout: bool = False):
super().__init__(sender)
self.widget = widget
self.layout = layout
Reported by Pylint.
Line: 25
Column: 5
yield self.sender
yield "widget"
def can_replace(self, message: Message) -> bool:
return isinstance(message, UpdateMessage) and self.widget is message.widget
@rich.repr.auto
class LayoutMessage(Message, verbosity=3):
Reported by Pylint.
Line: 30
Column: 1
@rich.repr.auto
class LayoutMessage(Message, verbosity=3):
def can_replace(self, message: Message) -> bool:
return isinstance(message, LayoutMessage)
Reported by Pylint.
Line: 30
Column: 1
@rich.repr.auto
class LayoutMessage(Message, verbosity=3):
def can_replace(self, message: Message) -> bool:
return isinstance(message, LayoutMessage)
Reported by Pylint.
docs/examples/timers/clock.py
11 issues
Line: 3
Column: 1
from datetime import datetime
from rich.align import Align
from textual.app import App
from textual.widget import Widget
class Clock(Widget):
Reported by Pylint.
Line: 5
Column: 1
from rich.align import Align
from textual.app import App
from textual.widget import Widget
class Clock(Widget):
def on_mount(self):
Reported by Pylint.
Line: 6
Column: 1
from rich.align import Align
from textual.app import App
from textual.widget import Widget
class Clock(Widget):
def on_mount(self):
self.set_interval(1, self.refresh)
Reported by Pylint.
Line: 1
Column: 1
from datetime import datetime
from rich.align import Align
from textual.app import App
from textual.widget import Widget
class Clock(Widget):
Reported by Pylint.
Line: 9
Column: 1
from textual.widget import Widget
class Clock(Widget):
def on_mount(self):
self.set_interval(1, self.refresh)
def render(self):
time = datetime.now().strftime("%c")
Reported by Pylint.
Line: 10
Column: 5
class Clock(Widget):
def on_mount(self):
self.set_interval(1, self.refresh)
def render(self):
time = datetime.now().strftime("%c")
return Align.center(time, vertical="middle")
Reported by Pylint.
Line: 13
Column: 5
def on_mount(self):
self.set_interval(1, self.refresh)
def render(self):
time = datetime.now().strftime("%c")
return Align.center(time, vertical="middle")
class ClockApp(App):
Reported by Pylint.
Line: 13
Column: 5
def on_mount(self):
self.set_interval(1, self.refresh)
def render(self):
time = datetime.now().strftime("%c")
return Align.center(time, vertical="middle")
class ClockApp(App):
Reported by Pylint.
Line: 18
Column: 1
return Align.center(time, vertical="middle")
class ClockApp(App):
async def on_mount(self):
await self.view.dock(Clock())
ClockApp.run()
Reported by Pylint.
Line: 18
Column: 1
return Align.center(time, vertical="middle")
class ClockApp(App):
async def on_mount(self):
await self.view.dock(Clock())
ClockApp.run()
Reported by Pylint.
src/textual/binding.py
11 issues
Line: 37
Column: 9
description: str = "",
show: bool = True,
key_display: str | None = None,
allow_forward: bool = True,
) -> None:
all_keys = [key.strip() for key in keys.split(",")]
for key in all_keys:
self.keys[key] = Binding(
key,
Reported by Pylint.
Line: 1
Column: 1
from __future__ import annotations
from dataclasses import dataclass
class NoBinding(Exception):
"""A binding was not found."""
@dataclass
Reported by Pylint.
Line: 10
Column: 1
@dataclass
class Binding:
key: str
action: str
description: str
show: bool = False
key_display: str | None = None
Reported by Pylint.
Line: 26
Column: 5
self.keys: dict[str, Binding] = {}
@property
def shown_keys(self) -> list[Binding]:
keys = [binding for binding in self.keys.values() if binding.show]
return keys
def bind(
self,
Reported by Pylint.
Line: 30
Column: 5
keys = [binding for binding in self.keys.values() if binding.show]
return keys
def bind(
self,
keys: str,
action: str,
description: str = "",
show: bool = True,
Reported by Pylint.
Line: 30
Column: 5
keys = [binding for binding in self.keys.values() if binding.show]
return keys
def bind(
self,
keys: str,
action: str,
description: str = "",
show: bool = True,
Reported by Pylint.
Line: 50
Column: 5
allow_forward=True,
)
def get_key(self, key: str) -> Binding:
try:
return self.keys[key]
except KeyError:
raise NoBinding(f"No binding for {key}") from None
Reported by Pylint.
Line: 56
Column: 5
except KeyError:
raise NoBinding(f"No binding for {key}") from None
def allow_forward(self, key: str) -> bool:
binding = self.keys.get(key, None)
if binding is None:
return True
return binding.allow_forward
Reported by Pylint.
Line: 69
Column: 5
def __init__(self, *bindings: Bindings) -> None:
self._stack: list[Bindings] = list(bindings)
def push(self, bindings: Bindings) -> None:
self._stack.append(bindings)
def pop(self) -> Bindings:
return self._stack.pop()
Reported by Pylint.
Line: 72
Column: 5
def push(self, bindings: Bindings) -> None:
self._stack.append(bindings)
def pop(self) -> Bindings:
return self._stack.pop()
def get_key(self, key: str) -> Binding:
for bindings in reversed(self._stack):
binding = bindings.keys.get(key, None)
Reported by Pylint.
examples/code_viewer.py
11 issues
Line: 3
Column: 1
import os
import sys
from rich.console import RenderableType
from rich.syntax import Syntax
from rich.traceback import Traceback
from textual.app import App
from textual.widgets import Header, Footer, FileClick, ScrollView, DirectoryTree
Reported by Pylint.
Line: 5
Column: 1
import sys
from rich.console import RenderableType
from rich.syntax import Syntax
from rich.traceback import Traceback
from textual.app import App
from textual.widgets import Header, Footer, FileClick, ScrollView, DirectoryTree
Reported by Pylint.
Line: 6
Column: 1
from rich.console import RenderableType
from rich.syntax import Syntax
from rich.traceback import Traceback
from textual.app import App
from textual.widgets import Header, Footer, FileClick, ScrollView, DirectoryTree
Reported by Pylint.
Line: 8
Column: 1
from rich.syntax import Syntax
from rich.traceback import Traceback
from textual.app import App
from textual.widgets import Header, Footer, FileClick, ScrollView, DirectoryTree
class MyApp(App):
"""An example of a very simple Textual App"""
Reported by Pylint.
Line: 9
Column: 1
from rich.traceback import Traceback
from textual.app import App
from textual.widgets import Header, Footer, FileClick, ScrollView, DirectoryTree
class MyApp(App):
"""An example of a very simple Textual App"""
Reported by Pylint.
Line: 24
Column: 13
# Get path to show
try:
self.path = sys.argv[1]
except IndexError:
self.path = os.path.abspath(
os.path.join(os.path.basename(__file__), "../../")
)
Reported by Pylint.
Line: 26
Column: 13
try:
self.path = sys.argv[1]
except IndexError:
self.path = os.path.abspath(
os.path.join(os.path.basename(__file__), "../../")
)
async def on_mount(self) -> None:
"""Call after terminal goes in to application mode"""
Reported by Pylint.
Line: 35
Column: 9
# Create our widgets
# In this a scroll view for the code and a directory tree
self.body = ScrollView()
self.directory = DirectoryTree(self.path, "Code")
# Dock our widgets
await self.view.dock(Header(), edge="top")
await self.view.dock(Footer(), edge="bottom")
Reported by Pylint.
Line: 36
Column: 9
# Create our widgets
# In this a scroll view for the code and a directory tree
self.body = ScrollView()
self.directory = DirectoryTree(self.path, "Code")
# Dock our widgets
await self.view.dock(Header(), edge="top")
await self.view.dock(Footer(), edge="bottom")
Reported by Pylint.
Line: 61
Column: 16
indent_guides=True,
theme="monokai",
)
except Exception:
# Possibly a binary file
# For demonstration purposes we will show the traceback
syntax = Traceback(theme="monokai", width=None, show_locals=True)
self.app.sub_title = os.path.basename(message.path)
await self.body.update(syntax)
Reported by Pylint.
src/textual/driver.py
10 issues
Line: 9
Column: 1
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING
from . import events
from ._types import MessageTarget
if TYPE_CHECKING:
from rich.console import Console
Reported by Pylint.
Line: 10
Column: 1
from typing import TYPE_CHECKING
from . import events
from ._types import MessageTarget
if TYPE_CHECKING:
from rich.console import Console
Reported by Pylint.
Line: 13
Column: 5
from ._types import MessageTarget
if TYPE_CHECKING:
from rich.console import Console
WINDOWS = platform.system() == "Windows"
Reported by Pylint.
Line: 10
Column: 1
from typing import TYPE_CHECKING
from . import events
from ._types import MessageTarget
if TYPE_CHECKING:
from rich.console import Console
Reported by Pylint.
Line: 1
Column: 1
from __future__ import annotations
import asyncio
from time import time
import platform
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING
from . import events
Reported by Pylint.
Line: 19
Column: 1
WINDOWS = platform.system() == "Windows"
class Driver(ABC):
def __init__(self, console: "Console", target: "MessageTarget") -> None:
self.console = console
self._target = target
self._loop = asyncio.get_event_loop()
self._mouse_down_time = time()
Reported by Pylint.
Line: 26
Column: 5
self._loop = asyncio.get_event_loop()
self._mouse_down_time = time()
def send_event(self, event: events.Event) -> None:
asyncio.run_coroutine_threadsafe(
self._target.post_message(event), loop=self._loop
)
def process_event(self, event: events.Event) -> None:
Reported by Pylint.
Line: 46
Column: 5
self.send_event(click_event)
@abstractmethod
def start_application_mode(self) -> None:
...
@abstractmethod
def disable_input(self) -> None:
...
Reported by Pylint.
Line: 50
Column: 5
...
@abstractmethod
def disable_input(self) -> None:
...
@abstractmethod
def stop_application_mode(self) -> None:
...
Reported by Pylint.
Line: 54
Column: 5
...
@abstractmethod
def stop_application_mode(self) -> None:
...
Reported by Pylint.
docs/examples/widgets/custom.py
10 issues
Line: 1
Column: 1
from rich.panel import Panel
from textual.app import App
from textual.reactive import Reactive
from textual.widget import Widget
class Hover(Widget):
Reported by Pylint.
Line: 3
Column: 1
from rich.panel import Panel
from textual.app import App
from textual.reactive import Reactive
from textual.widget import Widget
class Hover(Widget):
Reported by Pylint.
Line: 4
Column: 1
from rich.panel import Panel
from textual.app import App
from textual.reactive import Reactive
from textual.widget import Widget
class Hover(Widget):
Reported by Pylint.
Line: 5
Column: 1
from textual.app import App
from textual.reactive import Reactive
from textual.widget import Widget
class Hover(Widget):
mouse_over = Reactive(False)
Reported by Pylint.
Line: 1
Column: 1
from rich.panel import Panel
from textual.app import App
from textual.reactive import Reactive
from textual.widget import Widget
class Hover(Widget):
Reported by Pylint.
Line: 8
Column: 1
from textual.widget import Widget
class Hover(Widget):
mouse_over = Reactive(False)
def render(self) -> Panel:
return Panel("Hello [b]World[/b]", style=("on red" if self.mouse_over else ""))
Reported by Pylint.
Line: 12
Column: 5
mouse_over = Reactive(False)
def render(self) -> Panel:
return Panel("Hello [b]World[/b]", style=("on red" if self.mouse_over else ""))
def on_enter(self) -> None:
self.mouse_over = True
Reported by Pylint.
Line: 15
Column: 5
def render(self) -> Panel:
return Panel("Hello [b]World[/b]", style=("on red" if self.mouse_over else ""))
def on_enter(self) -> None:
self.mouse_over = True
def on_leave(self) -> None:
self.mouse_over = False
Reported by Pylint.
Line: 18
Column: 5
def on_enter(self) -> None:
self.mouse_over = True
def on_leave(self) -> None:
self.mouse_over = False
class HoverApp(App):
"""Demonstrates smooth animation"""
Reported by Pylint.
Line: 22
Column: 1
self.mouse_over = False
class HoverApp(App):
"""Demonstrates smooth animation"""
async def on_mount(self) -> None:
"""Build layout here."""
Reported by Pylint.