mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
remove _typing.py
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"""Simple version of 5x5, developed for/with Textual."""
|
||||
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, cast
|
||||
from typing_extensions import TYPE_CHECKING, cast
|
||||
|
||||
from rich.markdown import Markdown
|
||||
|
||||
@@ -15,7 +15,7 @@ from textual.widget import Widget
|
||||
from textual.widgets import Button, Footer, Label
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Final
|
||||
from typing_extensions import Final
|
||||
|
||||
|
||||
class Help(Screen):
|
||||
|
||||
@@ -4,14 +4,14 @@ import inspect
|
||||
|
||||
import rich.repr
|
||||
from rich.console import RenderableType
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import Callable, TYPE_CHECKING
|
||||
|
||||
from ._context import active_app
|
||||
from ._log import LogGroup, LogVerbosity
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Callable, TypeAlias
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
__all__ = ["log", "panic", "__version__"] # type: ignore
|
||||
|
||||
|
||||
@@ -5,13 +5,20 @@ import sys
|
||||
from abc import ABC, abstractmethod
|
||||
from dataclasses import dataclass
|
||||
from functools import partial
|
||||
from typing import TYPE_CHECKING, Any, Callable, TypeVar
|
||||
|
||||
from typing import Callable
|
||||
from typing_extensions import (
|
||||
TYPE_CHECKING,
|
||||
Any,
|
||||
Protocol,
|
||||
TypeVar,
|
||||
runtime_checkable,
|
||||
)
|
||||
|
||||
from . import _clock
|
||||
from ._callback import invoke
|
||||
from ._easing import DEFAULT_EASING, EASING
|
||||
from ._types import CallbackType
|
||||
from ._typing import Protocol, runtime_checkable
|
||||
from .timer import Timer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
||||
@@ -16,7 +16,7 @@ if sys.version_info >= (3, 8):
|
||||
else:
|
||||
import asyncio
|
||||
from asyncio import create_task as _create_task
|
||||
from typing import Awaitable
|
||||
from typing_extensions import Awaitable
|
||||
|
||||
def create_task(coroutine: Awaitable, *, name: str | None = None) -> asyncio.Task:
|
||||
"""Schedule the execution of a coroutine object in a spawn task."""
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from functools import lru_cache
|
||||
from typing import cast, Tuple, TYPE_CHECKING, Union
|
||||
from typing import cast, Tuple, Union
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from rich.segment import Segment
|
||||
from rich.style import Style
|
||||
@@ -10,7 +11,7 @@ from .color import Color
|
||||
from .css.types import EdgeStyle, EdgeType
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import TypeAlias
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
INNER = 1
|
||||
OUTER = 2
|
||||
|
||||
@@ -31,7 +31,7 @@ from .geometry import NULL_OFFSET, Offset, Region, Size
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .widget import Widget
|
||||
from typing import TypeAlias
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
|
||||
class ReflowResult(NamedTuple):
|
||||
|
||||
@@ -6,7 +6,7 @@ from typing import ClassVar, NamedTuple, TYPE_CHECKING
|
||||
from .geometry import Region, Size, Spacing
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import TypeAlias
|
||||
from typing_extensions import TypeAlias
|
||||
from .widget import Widget
|
||||
|
||||
ArrangeResult: TypeAlias = "tuple[list[WidgetPlacement], set[Widget]]"
|
||||
|
||||
@@ -4,7 +4,7 @@ from dataclasses import dataclass
|
||||
from fractions import Fraction
|
||||
from typing import Sequence, cast
|
||||
|
||||
from ._typing import Protocol
|
||||
from typing_extensions import Protocol
|
||||
|
||||
|
||||
class EdgeProtocol(Protocol):
|
||||
|
||||
@@ -2,9 +2,10 @@ from __future__ import annotations
|
||||
|
||||
from fractions import Fraction
|
||||
from itertools import accumulate
|
||||
from typing import TYPE_CHECKING, Sequence, cast
|
||||
from typing import Sequence, cast, TYPE_CHECKING
|
||||
|
||||
from typing_extensions import Literal
|
||||
|
||||
from ._typing import Literal
|
||||
from .box_model import BoxModel
|
||||
from .css.scalar import Scalar
|
||||
from .geometry import Size
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from typing import Awaitable, Callable, List, TYPE_CHECKING, Union
|
||||
from typing import Callable, List, Union
|
||||
from typing import Awaitable, TYPE_CHECKING
|
||||
|
||||
from rich.segment import Segment
|
||||
|
||||
from ._typing import Protocol
|
||||
from typing_extensions import Protocol
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
import sys
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Literal, Protocol, TypedDict, runtime_checkable
|
||||
else:
|
||||
if sys.version_info >= (3, 8):
|
||||
from typing import Literal, Protocol, TypedDict, runtime_checkable
|
||||
else:
|
||||
from typing_extensions import (
|
||||
Literal,
|
||||
Protocol,
|
||||
TypedDict,
|
||||
runtime_checkable,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"Literal",
|
||||
"Protocol",
|
||||
"runtime_checkable",
|
||||
"TypedDict",
|
||||
]
|
||||
@@ -46,11 +46,11 @@ from ._animator import DEFAULT_EASING, Animatable, Animator, EasingFunction
|
||||
from ._ansi_sequences import SYNC_END, SYNC_START
|
||||
from ._asyncio import create_task
|
||||
from ._callback import invoke
|
||||
from ._context import active_app, active_message_pump
|
||||
from ._context import active_app
|
||||
from ._event_broker import NoHandler, extract_handler_actions
|
||||
from ._filter import LineFilter, Monochrome
|
||||
from ._path import _make_path_object_relative
|
||||
from ._typing import Final
|
||||
|
||||
from ._wait import wait_for_idle
|
||||
from .actions import SkipAction
|
||||
from .await_remove import AwaitRemove
|
||||
@@ -72,7 +72,7 @@ from .screen import Screen
|
||||
from .widget import AwaitMount, Widget
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Coroutine, TypeAlias
|
||||
from typing_extensions import Coroutine, Final, TypeAlias
|
||||
|
||||
from .devtools.client import DevtoolsClient
|
||||
from .pilot import Pilot
|
||||
|
||||
@@ -8,7 +8,7 @@ import rich.repr
|
||||
from .keys import _character_to_key
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import TypeAlias
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
BindingType: TypeAlias = "Binding | tuple[str, str, str]"
|
||||
|
||||
|
||||
@@ -3,10 +3,11 @@ from __future__ import annotations
|
||||
from dataclasses import dataclass
|
||||
from typing import Iterable, Sequence
|
||||
|
||||
from textual._typing import Literal
|
||||
from textual.color import ColorParseError
|
||||
from textual.css._help_renderables import Example, Bullet, HelpText
|
||||
from textual.css.constants import (
|
||||
from typing import Literal
|
||||
|
||||
from ..color import ColorParseError
|
||||
from ._help_renderables import Example, Bullet, HelpText
|
||||
from .constants import (
|
||||
VALID_BORDER,
|
||||
VALID_LAYOUT,
|
||||
VALID_ALIGN_HORIZONTAL,
|
||||
|
||||
@@ -10,7 +10,14 @@ when setting and getting.
|
||||
from __future__ import annotations
|
||||
|
||||
from operator import attrgetter
|
||||
from typing import TYPE_CHECKING, Generic, Iterable, NamedTuple, TypeVar, cast
|
||||
from typing import (
|
||||
TYPE_CHECKING,
|
||||
Generic,
|
||||
Iterable,
|
||||
NamedTuple,
|
||||
TypeVar,
|
||||
cast,
|
||||
)
|
||||
|
||||
import rich.errors
|
||||
import rich.repr
|
||||
|
||||
@@ -4,7 +4,7 @@ import typing
|
||||
from ..geometry import Spacing
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from typing import Final
|
||||
from typing_extensions import Final
|
||||
from .types import EdgeType
|
||||
|
||||
VALID_VISIBILITY: Final = {"visible", "hidden"}
|
||||
|
||||
@@ -4,7 +4,8 @@ from abc import ABC, abstractmethod
|
||||
from dataclasses import dataclass, field
|
||||
from functools import lru_cache
|
||||
from operator import attrgetter
|
||||
from typing import TYPE_CHECKING, Any, Iterable, NamedTuple, cast
|
||||
from typing import Iterable, cast
|
||||
from typing import TYPE_CHECKING, Any, NamedTuple, TypedDict
|
||||
|
||||
import rich.repr
|
||||
from rich.style import Style
|
||||
@@ -62,8 +63,6 @@ from .types import (
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import TypedDict
|
||||
|
||||
from .._layout import Layout
|
||||
from ..dom import DOMNode
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Tuple
|
||||
from typing_extensions import Literal
|
||||
|
||||
from ..color import Color
|
||||
from .._typing import Literal
|
||||
|
||||
Edge = Literal["top", "right", "bottom", "left"]
|
||||
DockEdge = Literal["top", "right", "bottom", "left", ""]
|
||||
|
||||
@@ -5,7 +5,6 @@ from pathlib import Path
|
||||
from typing import Iterable
|
||||
|
||||
from importlib_metadata import version
|
||||
|
||||
from rich.align import Align
|
||||
from rich.console import Console, ConsoleOptions, RenderResult
|
||||
from rich.markup import escape
|
||||
@@ -15,8 +14,9 @@ from rich.style import Style
|
||||
from rich.styled import Styled
|
||||
from rich.table import Table
|
||||
from rich.text import Text
|
||||
from typing_extensions import Literal
|
||||
|
||||
from textual._log import LogGroup
|
||||
from textual._typing import Literal
|
||||
|
||||
DevConsoleMessageLevel = Literal["info", "warning", "error"]
|
||||
|
||||
|
||||
@@ -40,9 +40,9 @@ if TYPE_CHECKING:
|
||||
from .css.query import DOMQuery
|
||||
from .screen import Screen
|
||||
from .widget import Widget
|
||||
from typing import TypeAlias
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from ._typing import Literal
|
||||
from typing_extensions import Literal
|
||||
|
||||
_re_identifier = re.compile(IDENTIFIER)
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, cast
|
||||
from typing import TYPE_CHECKING, Literal, cast
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Final, Literal
|
||||
from typing_extensions import Final
|
||||
|
||||
FEATURES: Final = {"devtools", "debug", "headless"}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ from typing import (
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import TypeAlias
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
|
||||
SpacingDimensions: TypeAlias = Union[
|
||||
|
||||
@@ -20,7 +20,7 @@ from .renderables.blank import Blank
|
||||
from .widget import Widget
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Final
|
||||
from typing_extensions import Final
|
||||
|
||||
# Screen updates will be batched so that they don't happen more often than 120 times per second:
|
||||
UPDATE_PERIOD: Final[float] = 1 / 120
|
||||
|
||||
@@ -2,6 +2,7 @@ from __future__ import annotations
|
||||
|
||||
from functools import partial
|
||||
from typing import cast
|
||||
from typing_extensions import Literal
|
||||
|
||||
import rich.repr
|
||||
from rich.console import RenderableType
|
||||
@@ -12,7 +13,7 @@ from ..css._error_tools import friendly_list
|
||||
from ..message import Message
|
||||
from ..reactive import Reactive
|
||||
from ..widgets import Static
|
||||
from .._typing import Literal
|
||||
|
||||
|
||||
ButtonVariant = Literal["default", "primary", "success", "warning", "error"]
|
||||
_VALID_BUTTON_VARIANTS = {"default", "primary", "success", "warning", "error"}
|
||||
|
||||
@@ -2,7 +2,8 @@ from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from itertools import chain, zip_longest
|
||||
from typing import ClassVar, Generic, Iterable, TypeVar, cast
|
||||
from typing import Generic, Iterable, cast
|
||||
from typing_extensions import ClassVar, TypeVar, Literal
|
||||
|
||||
import rich.repr
|
||||
from rich.console import RenderableType
|
||||
@@ -16,7 +17,6 @@ from .. import events, messages
|
||||
from .._cache import LRUCache
|
||||
from .._segment_tools import line_crop
|
||||
from .._types import SegmentLines
|
||||
from .._typing import Literal
|
||||
from ..binding import Binding, BindingType
|
||||
from ..coordinate import Coordinate
|
||||
from ..geometry import Region, Size, Spacing, clamp
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from __future__ import annotations
|
||||
from typing import ClassVar
|
||||
|
||||
from textual import events
|
||||
from textual.await_remove import AwaitRemove
|
||||
from textual.binding import Binding, BindingType
|
||||
from textual.containers import Vertical
|
||||
|
||||
@@ -2,11 +2,13 @@ from __future__ import annotations
|
||||
|
||||
from itertools import cycle
|
||||
|
||||
from typing_extensions import Literal
|
||||
|
||||
from .. import events
|
||||
from ..css._error_tools import friendly_list
|
||||
from ..reactive import Reactive, reactive
|
||||
from ..widget import Widget, RenderResult
|
||||
from .._typing import Literal
|
||||
|
||||
|
||||
PlaceholderVariant = Literal["default", "size", "text"]
|
||||
_VALID_PLACEHOLDER_VARIANTS_ORDERED: list[PlaceholderVariant] = [
|
||||
|
||||
@@ -10,10 +10,10 @@ from rich.protocol import is_renderable
|
||||
from rich.segment import Segment
|
||||
from rich.text import Text
|
||||
|
||||
from ..reactive import var
|
||||
from ..geometry import Size, Region
|
||||
from ..scroll_view import ScrollView
|
||||
from .._cache import LRUCache
|
||||
from ..geometry import Region, Size
|
||||
from ..reactive import var
|
||||
from ..scroll_view import ScrollView
|
||||
from ..strip import Strip
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ from ..scroll_view import ScrollView
|
||||
from ..strip import Strip
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import TypeAlias
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
NodeID = NewType("NodeID", int)
|
||||
TreeDataType = TypeVar("TreeDataType")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from contextlib import nullcontext as does_not_raise
|
||||
from typing import Any
|
||||
from typing_extensions import Any
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -118,7 +118,6 @@ def pytest_sessionfinish(
|
||||
diffs: List[SvgSnapshotDiff] = []
|
||||
num_snapshots_passing = 0
|
||||
for item in session.items:
|
||||
|
||||
# Grab the data our fixture attached to the pytest node
|
||||
num_snapshots_passing += int(item.stash.get(TEXTUAL_SNAPSHOT_PASS, False))
|
||||
snapshot_svg = item.stash.get(TEXTUAL_SNAPSHOT_SVG_KEY, None)
|
||||
|
||||
@@ -3,6 +3,7 @@ import pytest
|
||||
from typing import Sequence
|
||||
from textual._immutable_sequence_view import ImmutableSequenceView
|
||||
|
||||
|
||||
def wrap(source: Sequence[int]) -> ImmutableSequenceView[int]:
|
||||
"""Wrap a sequence of integers inside an immutable sequence view."""
|
||||
return ImmutableSequenceView[int](source)
|
||||
|
||||
Reference in New Issue
Block a user