mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Merge branch 'main' into switch-redux
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -110,6 +110,9 @@ venv.bak/
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
/docs-offline
|
||||
/mkdocs-nav-online.yml
|
||||
/mkdocs-nav-offline.yml
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
# See https://pre-commit.com for more information
|
||||
# See https://pre-commit.com/hooks.html for more hooks
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.3.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
- id: end-of-file-fixer
|
||||
- id: check-yaml
|
||||
args: ['--unsafe']
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 22.10.0
|
||||
- id: trailing-whitespace
|
||||
- id: end-of-file-fixer
|
||||
- id: check-yaml
|
||||
args: [ '--unsafe' ]
|
||||
- repo: https://github.com/pycqa/isort
|
||||
rev: 5.12.0
|
||||
hooks:
|
||||
- id: black
|
||||
- id: isort
|
||||
name: isort (python)
|
||||
language_version: '3.11'
|
||||
args: ["--profile", "black", "--filter-files"]
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 23.1.0
|
||||
hooks:
|
||||
- id: black
|
||||
exclude: ^tests/snapshot_tests
|
||||
|
||||
76
Makefile
76
Makefile
@@ -1,20 +1,70 @@
|
||||
run := poetry run
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
pytest --cov-report term-missing --cov=textual tests/ -vv
|
||||
$(run) pytest --cov-report term-missing --cov=textual tests/ -vv
|
||||
|
||||
.PHONY: unit-test
|
||||
unit-test:
|
||||
pytest --cov-report term-missing --cov=textual tests/ -vv -m "not integration_test"
|
||||
$(run) pytest --cov-report term-missing --cov=textual tests/ -vv -m "not integration_test"
|
||||
|
||||
.PHONY: test-snapshot-update
|
||||
test-snapshot-update:
|
||||
pytest --cov-report term-missing --cov=textual tests/ -vv --snapshot-update
|
||||
$(run) pytest --cov-report term-missing --cov=textual tests/ -vv --snapshot-update
|
||||
|
||||
.PHONY: typecheck
|
||||
typecheck:
|
||||
mypy src/textual
|
||||
$(run) mypy src/textual
|
||||
|
||||
.PHONY: format
|
||||
format:
|
||||
black src
|
||||
$(run) black src
|
||||
|
||||
.PHONY: format-check
|
||||
format-check:
|
||||
black --check src
|
||||
docs-serve:
|
||||
$(run) black --check src
|
||||
|
||||
.PHONY: clean-screenshot-cache
|
||||
clean-screenshot-cache:
|
||||
rm -rf .screenshot_cache
|
||||
mkdocs serve
|
||||
docs-build:
|
||||
mkdocs build
|
||||
docs-deploy:
|
||||
rm -rf .screenshot_cache
|
||||
mkdocs gh-deploy
|
||||
|
||||
.PHONY: docs-offline-nav
|
||||
docs-offline-nav:
|
||||
echo "INHERIT: mkdocs-offline.yml" > mkdocs-nav-offline.yml
|
||||
grep -v "\- \"*[Bb]log" mkdocs-nav.yml >> mkdocs-nav-offline.yml
|
||||
|
||||
.PHONY: docs-online-nav
|
||||
docs-online-nav:
|
||||
echo "INHERIT: mkdocs-online.yml" > mkdocs-nav-online.yml
|
||||
cat mkdocs-nav.yml >> mkdocs-nav-online.yml
|
||||
|
||||
.PHONY: docs-serve
|
||||
docs-serve: clean-screenshot-cache docs-online-nav
|
||||
$(run) mkdocs serve --config-file mkdocs-nav-online.yml
|
||||
rm -f mkdocs-nav-online.yml
|
||||
|
||||
.PHONY: docs-build
|
||||
docs-build: docs-online-nav
|
||||
$(run) mkdocs build --config-file mkdocs-nav-online.yml
|
||||
rm -f mkdocs-nav-online.yml
|
||||
|
||||
.PHONY: docs-build-offline
|
||||
docs-build-offline: docs-offline-nav
|
||||
$(run) mkdocs build --config-file mkdocs-nav-offline.yml
|
||||
rm -f mkdocs-nav-offline.yml
|
||||
|
||||
.PHONY: clean-offline-docs
|
||||
clean-offline-docs:
|
||||
rm -rf docs-offline
|
||||
|
||||
.PHONY: docs-deploy
|
||||
docs-deploy: clean-screenshot-cache docs-online-nav
|
||||
$(run) mkdocs gh-deploy --config-file mkdocs-nav-online.yml
|
||||
rm -f mkdocs-nav-online.yml
|
||||
|
||||
.PHONY: build
|
||||
build: docs-build-offline
|
||||
poetry build
|
||||
|
||||
.PHONY: clean
|
||||
clean: clean-screenshot-cache clean-offline-docs
|
||||
|
||||
@@ -183,7 +183,7 @@ Let's look at an example which looks up word definitions from an [api](https://d
|
||||
|
||||
=== "Output"
|
||||
|
||||
```{.textual path="docs/examples/events/dictionary.py" press="t,e,x,t,_,_,_,_,_,_,_,_,_,_,_"}
|
||||
```{.textual path="docs/examples/events/dictionary.py"}
|
||||
```
|
||||
|
||||
Note the highlighted line in the above code which calls `asyncio.create_task` to run a coroutine in the background. Without this you would find typing in to the text box to be unresponsive.
|
||||
|
||||
@@ -81,10 +81,6 @@ Build sophisticated user interfaces with a simple Python API. Run your apps in t
|
||||
```
|
||||
|
||||
|
||||
```{.textual path="docs/examples/events/dictionary.py" columns="100" lines="30" press="tab,_,t,e,x,t,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_"}
|
||||
```
|
||||
|
||||
|
||||
```{.textual path="docs/examples/guide/layout/combining_layouts.py" columns="100", lines="30"}
|
||||
```
|
||||
|
||||
|
||||
100
mkdocs-common.yml
Normal file
100
mkdocs-common.yml
Normal file
@@ -0,0 +1,100 @@
|
||||
site_name: Textual
|
||||
|
||||
markdown_extensions:
|
||||
- attr_list
|
||||
- pymdownx.emoji:
|
||||
emoji_index: !!python/name:materialx.emoji.twemoji
|
||||
emoji_generator: !!python/name:materialx.emoji.to_svg
|
||||
- md_in_html
|
||||
- admonition
|
||||
- def_list
|
||||
- meta
|
||||
|
||||
- toc:
|
||||
permalink: true
|
||||
baselevel: 1
|
||||
- pymdownx.keys
|
||||
- pymdownx.tasklist:
|
||||
custom_checkbox: true
|
||||
- pymdownx.highlight:
|
||||
anchor_linenums: true
|
||||
- pymdownx.inlinehilite
|
||||
- pymdownx.superfences:
|
||||
custom_fences:
|
||||
- name: textual
|
||||
class: textual
|
||||
format: !!python/name:textual._doc.format_svg
|
||||
- name: rich
|
||||
class: rich
|
||||
format: !!python/name:textual._doc.rich
|
||||
- pymdownx.inlinehilite
|
||||
- pymdownx.superfences
|
||||
- pymdownx.snippets
|
||||
- pymdownx.tabbed:
|
||||
alternate_style: true
|
||||
- pymdownx.snippets
|
||||
- markdown.extensions.attr_list
|
||||
|
||||
theme:
|
||||
name: material
|
||||
custom_dir: docs/custom_theme
|
||||
features:
|
||||
- navigation.tabs
|
||||
- navigation.indexes
|
||||
- navigation.tabs.sticky
|
||||
- navigation.footer
|
||||
- content.code.annotate
|
||||
- content.code.copy
|
||||
palette:
|
||||
- media: "(prefers-color-scheme: light)"
|
||||
scheme: default
|
||||
accent: purple
|
||||
toggle:
|
||||
icon: material/weather-sunny
|
||||
name: Switch to dark mode
|
||||
- media: "(prefers-color-scheme: dark)"
|
||||
scheme: slate
|
||||
primary: black
|
||||
toggle:
|
||||
icon: material/weather-night
|
||||
name: Switch to light mode
|
||||
|
||||
plugins:
|
||||
search:
|
||||
autorefs:
|
||||
mkdocstrings:
|
||||
custom_templates: docs/_templates
|
||||
default_handler: python
|
||||
handlers:
|
||||
python:
|
||||
options:
|
||||
show_root_heading: true
|
||||
show_root_full_path: false
|
||||
show_source: false
|
||||
filters:
|
||||
- "!^_"
|
||||
- "^__init__$"
|
||||
- "!^can_replace$"
|
||||
watch:
|
||||
- src/textual
|
||||
exclude:
|
||||
glob:
|
||||
- "**/_template.md"
|
||||
|
||||
|
||||
extra_css:
|
||||
- stylesheets/custom.css
|
||||
|
||||
|
||||
extra:
|
||||
social:
|
||||
- icon: fontawesome/brands/twitter
|
||||
link: https://twitter.com/textualizeio
|
||||
name: textualizeio on Twitter
|
||||
- icon: fontawesome/brands/github
|
||||
link: https://github.com/textualize/textual/
|
||||
name: Textual on Github
|
||||
- icon: fontawesome/brands/discord
|
||||
link: https://discord.gg/Enf6Z3qhVr
|
||||
name: Textual Discord server
|
||||
copyright: Copyright © Textualize, Inc
|
||||
@@ -1,8 +1,3 @@
|
||||
site_name: Textual
|
||||
site_url: https://textual.textualize.io/
|
||||
repo_url: https://github.com/textualize/textual/
|
||||
edit_uri: edit/main/docs/
|
||||
|
||||
nav:
|
||||
- Introduction:
|
||||
- "index.md"
|
||||
@@ -178,114 +173,3 @@ nav:
|
||||
- "api/widget.md"
|
||||
- "Blog":
|
||||
- blog/index.md
|
||||
|
||||
|
||||
|
||||
markdown_extensions:
|
||||
- attr_list
|
||||
- pymdownx.emoji:
|
||||
emoji_index: !!python/name:materialx.emoji.twemoji
|
||||
emoji_generator: !!python/name:materialx.emoji.to_svg
|
||||
- md_in_html
|
||||
- admonition
|
||||
- def_list
|
||||
- meta
|
||||
|
||||
- toc:
|
||||
permalink: true
|
||||
baselevel: 1
|
||||
- pymdownx.keys
|
||||
- pymdownx.tasklist:
|
||||
custom_checkbox: true
|
||||
- pymdownx.highlight:
|
||||
anchor_linenums: true
|
||||
- pymdownx.inlinehilite
|
||||
- pymdownx.superfences:
|
||||
custom_fences:
|
||||
- name: textual
|
||||
class: textual
|
||||
format: !!python/name:textual._doc.format_svg
|
||||
- name: rich
|
||||
class: rich
|
||||
format: !!python/name:textual._doc.rich
|
||||
- pymdownx.inlinehilite
|
||||
- pymdownx.superfences
|
||||
- pymdownx.snippets
|
||||
- pymdownx.tabbed:
|
||||
alternate_style: true
|
||||
- pymdownx.snippets
|
||||
- markdown.extensions.attr_list
|
||||
|
||||
theme:
|
||||
name: material
|
||||
custom_dir: docs/custom_theme
|
||||
features:
|
||||
- navigation.tabs
|
||||
- navigation.indexes
|
||||
- navigation.tabs.sticky
|
||||
- navigation.footer
|
||||
- content.code.annotate
|
||||
- content.code.copy
|
||||
palette:
|
||||
- media: "(prefers-color-scheme: light)"
|
||||
scheme: default
|
||||
accent: purple
|
||||
toggle:
|
||||
icon: material/weather-sunny
|
||||
name: Switch to dark mode
|
||||
- media: "(prefers-color-scheme: dark)"
|
||||
scheme: slate
|
||||
primary: black
|
||||
toggle:
|
||||
icon: material/weather-night
|
||||
name: Switch to light mode
|
||||
|
||||
plugins:
|
||||
|
||||
- blog:
|
||||
- rss:
|
||||
match_path: blog/posts/.*
|
||||
date_from_meta:
|
||||
as_creation: date
|
||||
categories:
|
||||
- categories
|
||||
- release
|
||||
- tags
|
||||
- search:
|
||||
- autorefs:
|
||||
- mkdocstrings:
|
||||
custom_templates: docs/_templates
|
||||
default_handler: python
|
||||
handlers:
|
||||
python:
|
||||
options:
|
||||
show_root_heading: true
|
||||
show_root_full_path: false
|
||||
show_source: false
|
||||
filters:
|
||||
- "!^_"
|
||||
- "^__init__$"
|
||||
- "!^can_replace$"
|
||||
watch:
|
||||
- src/textual
|
||||
- exclude:
|
||||
glob:
|
||||
- "**/_template.md"
|
||||
|
||||
|
||||
extra_css:
|
||||
- stylesheets/custom.css
|
||||
|
||||
|
||||
extra:
|
||||
social:
|
||||
- icon: fontawesome/brands/twitter
|
||||
link: https://twitter.com/textualizeio
|
||||
name: textualizeio on Twitter
|
||||
- icon: fontawesome/brands/github
|
||||
link: https://github.com/textualize/textual/
|
||||
name: Textual on Github
|
||||
- icon: fontawesome/brands/discord
|
||||
link: https://discord.gg/Enf6Z3qhVr
|
||||
name: Textual Discord server
|
||||
copyright: Copyright © Textualize, Inc
|
||||
11
mkdocs-offline.yml
Normal file
11
mkdocs-offline.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
INHERIT: mkdocs-common.yml
|
||||
|
||||
plugins:
|
||||
offline:
|
||||
privacy:
|
||||
exclude:
|
||||
glob:
|
||||
- "**/_template.md"
|
||||
- blog/*
|
||||
|
||||
site_dir: docs-offline
|
||||
16
mkdocs-online.yml
Normal file
16
mkdocs-online.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
INHERIT: mkdocs-common.yml
|
||||
|
||||
repo_url: https://github.com/textualize/textual/
|
||||
site_url: https://textual.textualize.io/
|
||||
edit_uri: edit/main/docs/
|
||||
|
||||
plugins:
|
||||
blog:
|
||||
rss:
|
||||
match_path: blog/posts/.*
|
||||
date_from_meta:
|
||||
as_creation: date
|
||||
categories:
|
||||
- categories
|
||||
- release
|
||||
- tags
|
||||
2374
poetry.lock
generated
2374
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -24,7 +24,13 @@ classifiers = [
|
||||
include = [
|
||||
"src/textual/py.typed",
|
||||
{ path = "docs/examples", format = "sdist" },
|
||||
{ path = "tests", format = "sdist" }
|
||||
{ path = "tests", format = "sdist" },
|
||||
# The reason for the slightly convoluted path specification here is that
|
||||
# poetry populates the exclude list with the content of .gitignore, and
|
||||
# it also seems like exclude trumps include. So here we specify that we
|
||||
# want to package up the content of the docs-offline directory in a way
|
||||
# that works around that.
|
||||
{ path = "docs-offline/**/*", format = "sdist" }
|
||||
]
|
||||
|
||||
[tool.poetry.scripts]
|
||||
@@ -54,7 +60,7 @@ mypy = "^1.0.0"
|
||||
pytest-cov = "^2.12.1"
|
||||
mkdocs = "^1.3.0"
|
||||
mkdocstrings = {extras = ["python"], version = "^0.20.0"}
|
||||
mkdocs-material = "^8.2.15"
|
||||
mkdocs-material = "^9.0.11"
|
||||
pre-commit = "^2.13.0"
|
||||
pytest-aiohttp = "^1.0.4"
|
||||
time-machine = "^2.6.0"
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import inspect
|
||||
from typing import TYPE_CHECKING, Callable
|
||||
|
||||
import rich.repr
|
||||
from rich.console import RenderableType
|
||||
from typing import Callable, TYPE_CHECKING
|
||||
|
||||
from ._context import active_app
|
||||
from ._log import LogGroup, LogVerbosity
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from .demo import DemoApp
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = DemoApp()
|
||||
app.run()
|
||||
|
||||
@@ -3,11 +3,11 @@ from __future__ import annotations
|
||||
from collections import defaultdict
|
||||
from fractions import Fraction
|
||||
from operator import attrgetter
|
||||
from typing import Sequence, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Sequence
|
||||
|
||||
from .geometry import Region, Size, Spacing
|
||||
from ._layout import DockArrangeResult, WidgetPlacement
|
||||
from ._partition import partition
|
||||
from .geometry import Region, Size, Spacing
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .widget import Widget
|
||||
|
||||
@@ -5,7 +5,6 @@ Compatibility layer for asyncio.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
import sys
|
||||
|
||||
__all__ = ["create_task"]
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from functools import lru_cache
|
||||
from typing import cast, Tuple, Union
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Tuple, Union, cast
|
||||
|
||||
from rich.segment import Segment
|
||||
from rich.style import Style
|
||||
|
||||
@@ -2,8 +2,8 @@ from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from functools import lru_cache
|
||||
from inspect import signature, isawaitable
|
||||
from typing import Any, Callable, TYPE_CHECKING
|
||||
from inspect import isawaitable, signature
|
||||
from typing import TYPE_CHECKING, Any, Callable
|
||||
|
||||
from . import active_app
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import asyncio
|
||||
|
||||
from ._time import time
|
||||
|
||||
|
||||
"""
|
||||
A module that serves as the single source of truth for everything time-related in a Textual app.
|
||||
Having this logic centralised makes it easier to simulate time in integration tests,
|
||||
|
||||
@@ -25,14 +25,14 @@ from rich.style import Style
|
||||
from . import errors
|
||||
from ._cells import cell_len
|
||||
from ._loop import loop_last
|
||||
from .strip import Strip
|
||||
from .geometry import NULL_OFFSET, Offset, Region, Size
|
||||
|
||||
from .strip import Strip
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .widget import Widget
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from .widget import Widget
|
||||
|
||||
|
||||
class ReflowResult(NamedTuple):
|
||||
"""The result of a reflow operation. Describes the chances to widgets."""
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from contextvars import ContextVar
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .app import App
|
||||
|
||||
@@ -2,14 +2,13 @@ from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shlex
|
||||
from pathlib import Path
|
||||
from typing import Iterable
|
||||
|
||||
from textual._import_app import import_app
|
||||
from textual.app import App
|
||||
from textual.pilot import Pilot
|
||||
from textual._import_app import import_app
|
||||
|
||||
|
||||
SCREENSHOT_CACHE = ".screenshot_cache"
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ Define a series of easing functions for more natural-looking animations.
|
||||
Taken from https://easings.net/ and translated from JavaScript.
|
||||
"""
|
||||
|
||||
from math import pi, cos, sin, sqrt
|
||||
from math import cos, pi, sin, sqrt
|
||||
|
||||
|
||||
def _in_out_expo(x: float) -> float:
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
"""Provides an immutable sequence view class."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from sys import maxsize
|
||||
from typing import Generic, TypeVar, Iterator, overload, Sequence
|
||||
from typing import Generic, Iterator, Sequence, TypeVar, overload
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
import runpy
|
||||
import shlex
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import cast, TYPE_CHECKING
|
||||
|
||||
from typing import TYPE_CHECKING, cast
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from textual.app import App
|
||||
@@ -46,10 +45,10 @@ def import_app(import_name: str) -> App:
|
||||
A Textual application
|
||||
"""
|
||||
|
||||
import inspect
|
||||
import importlib
|
||||
import inspect
|
||||
|
||||
from textual.app import App, WINDOWS
|
||||
from textual.app import WINDOWS, App
|
||||
|
||||
import_name, *argv = shlex.split(import_name, posix=not WINDOWS)
|
||||
drive, import_name = os.path.splitdrive(import_name)
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import ClassVar, NamedTuple, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, ClassVar, NamedTuple
|
||||
|
||||
from .geometry import Region, Size, Spacing
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from .widget import Widget
|
||||
|
||||
ArrangeResult: TypeAlias = "tuple[list[WidgetPlacement], set[Widget]]"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
import sys
|
||||
|
||||
import sys
|
||||
from typing import TYPE_CHECKING, Any, Iterator, Sequence, overload
|
||||
|
||||
import rich.repr
|
||||
|
||||
@@ -1,16 +1,8 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections import deque
|
||||
import io
|
||||
from typing import (
|
||||
Callable,
|
||||
Deque,
|
||||
Generator,
|
||||
TypeVar,
|
||||
Generic,
|
||||
Union,
|
||||
Iterable,
|
||||
)
|
||||
from collections import deque
|
||||
from typing import Callable, Deque, Generator, Generic, Iterable, TypeVar, Union
|
||||
|
||||
|
||||
class ParseError(Exception):
|
||||
|
||||
@@ -2,7 +2,6 @@ from __future__ import annotations
|
||||
|
||||
from typing import Callable, Iterable, TypeVar
|
||||
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ Timer context manager, only used in debug.
|
||||
"""
|
||||
|
||||
import contextlib
|
||||
from typing import Generator
|
||||
from time import perf_counter
|
||||
from typing import Generator
|
||||
|
||||
from . import log
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ from __future__ import annotations
|
||||
|
||||
from fractions import Fraction
|
||||
from itertools import accumulate
|
||||
from typing import Sequence, cast, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Sequence, cast
|
||||
|
||||
from typing_extensions import Literal
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
from time import sleep, perf_counter
|
||||
from asyncio import get_running_loop, Future
|
||||
from threading import Thread, Event
|
||||
from asyncio import Future, get_running_loop
|
||||
from threading import Event, Thread
|
||||
from time import perf_counter, sleep
|
||||
|
||||
|
||||
class Sleeper(Thread):
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from asyncio import sleep
|
||||
from time import process_time, monotonic
|
||||
from time import monotonic, process_time
|
||||
|
||||
SLEEP_GRANULARITY: float = 1 / 50
|
||||
SLEEP_IDLE: float = SLEEP_GRANULARITY / 2.0
|
||||
|
||||
@@ -7,7 +7,6 @@ This should only be imported on Windows.
|
||||
|
||||
from time import sleep as time_sleep
|
||||
|
||||
|
||||
__all__ = ["sleep"]
|
||||
|
||||
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import unicodedata
|
||||
import re
|
||||
import unicodedata
|
||||
from typing import Any, Callable, Generator, Iterable
|
||||
|
||||
from . import events
|
||||
from . import messages
|
||||
from . import events, messages
|
||||
from ._ansi_sequences import ANSI_SEQUENCES_KEYS
|
||||
from ._parser import Awaitable, Parser, TokenCallback
|
||||
from ._types import MessageTarget
|
||||
from .keys import KEY_NAME_REPLACEMENTS
|
||||
|
||||
|
||||
# When trying to determine whether the current sequence is a supported/valid
|
||||
# escape sequence, at which length should we give up and consider our search
|
||||
# to be unsuccessful?
|
||||
|
||||
@@ -50,7 +50,6 @@ 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 ._wait import wait_for_idle
|
||||
from .actions import SkipAction
|
||||
from .await_remove import AwaitRemove
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import re
|
||||
|
||||
from typing import Match, Pattern
|
||||
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ except ImportError:
|
||||
|
||||
from importlib_metadata import version
|
||||
|
||||
from textual._import_app import AppFail, import_app
|
||||
from textual.pilot import Pilot
|
||||
from textual._import_app import import_app, AppFail
|
||||
|
||||
|
||||
@click.group()
|
||||
@@ -26,6 +26,7 @@ def run():
|
||||
def console(verbose: bool, exclude: list[str]) -> None:
|
||||
"""Launch the textual console."""
|
||||
from rich.console import Console
|
||||
|
||||
from textual.devtools.server import _run_devtools
|
||||
|
||||
console = Console()
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.constants import BORDERS
|
||||
from textual.widgets import Button, Label
|
||||
from textual.containers import Vertical
|
||||
|
||||
from textual.widgets import Button, Label
|
||||
|
||||
TEXT = """I must not fear.
|
||||
Fear is the mind-killer.
|
||||
|
||||
@@ -2,7 +2,7 @@ from textual.app import App, ComposeResult
|
||||
from textual.containers import Horizontal, Vertical
|
||||
from textual.design import ColorSystem
|
||||
from textual.widget import Widget
|
||||
from textual.widgets import Button, Footer, Static, Label
|
||||
from textual.widgets import Button, Footer, Label, Static
|
||||
|
||||
|
||||
class ColorButtons(Vertical):
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from rich.console import RenderableType
|
||||
|
||||
from textual._easing import EASING
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.cli.previews.borders import TEXT
|
||||
@@ -8,7 +9,7 @@ from textual.containers import Container, Horizontal, Vertical
|
||||
from textual.reactive import reactive, var
|
||||
from textual.scrollbar import ScrollBarRender
|
||||
from textual.widget import Widget
|
||||
from textual.widgets import Button, Footer, Label, Input
|
||||
from textual.widgets import Button, Footer, Input, Label
|
||||
|
||||
VIRTUAL_SIZE = 100
|
||||
WINDOW_SIZE = 10
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from rich.panel import Panel
|
||||
|
||||
from rich.text import Text
|
||||
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.reactive import var, Reactive
|
||||
from textual import events
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.containers import Horizontal
|
||||
from textual.reactive import Reactive, var
|
||||
from textual.widgets import Button, Header, TextLog
|
||||
|
||||
|
||||
INSTRUCTIONS = """\
|
||||
[u]Press some keys![/]
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
"""Textual CLI command code to print diagnostic information."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
import platform
|
||||
from typing import Any
|
||||
import sys
|
||||
from functools import singledispatch
|
||||
from typing import Any
|
||||
|
||||
from importlib_metadata import version
|
||||
from rich.console import Console, ConsoleDimensions
|
||||
|
||||
|
||||
@@ -5,20 +5,20 @@ from typing import Iterable, Sequence
|
||||
|
||||
from typing_extensions import Literal
|
||||
|
||||
from textual.css._error_tools import friendly_list
|
||||
from textual.css.scalar import SYMBOL_UNIT
|
||||
|
||||
from ..color import ColorParseError
|
||||
from ._help_renderables import Example, Bullet, HelpText
|
||||
from ._help_renderables import Bullet, Example, HelpText
|
||||
from .constants import (
|
||||
VALID_BORDER,
|
||||
VALID_LAYOUT,
|
||||
VALID_ALIGN_HORIZONTAL,
|
||||
VALID_ALIGN_VERTICAL,
|
||||
VALID_BORDER,
|
||||
VALID_LAYOUT,
|
||||
VALID_STYLE_FLAGS,
|
||||
VALID_TEXT_ALIGN,
|
||||
)
|
||||
|
||||
from textual.css._error_tools import friendly_list
|
||||
from textual.css.scalar import SYMBOL_UNIT
|
||||
|
||||
StylingContext = Literal["inline", "css"]
|
||||
"""The type of styling the user was using when the error was encountered.
|
||||
Used to give help text specific to the context i.e. we give CSS help if the
|
||||
|
||||
@@ -10,14 +10,7 @@ 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
|
||||
@@ -611,11 +604,8 @@ class LayoutProperty:
|
||||
or a ``Layout`` object.
|
||||
"""
|
||||
|
||||
from ..layouts.factory import (
|
||||
Layout, # Prevents circular import
|
||||
MissingLayout,
|
||||
get_layout,
|
||||
)
|
||||
from ..layouts.factory import Layout # Prevents circular import
|
||||
from ..layouts.factory import MissingLayout, get_layout
|
||||
|
||||
_rich_traceback_omit = True
|
||||
if layout is None:
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import typing
|
||||
|
||||
from ..geometry import Spacing
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from rich.console import ConsoleOptions, Console, RenderResult
|
||||
from rich.console import Console, ConsoleOptions, RenderResult
|
||||
from rich.traceback import Traceback
|
||||
|
||||
from ._help_renderables import HelpText
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Iterable, TYPE_CHECKING
|
||||
from .model import CombinatorType, Selector, SelectorSet
|
||||
from typing import TYPE_CHECKING, Iterable
|
||||
|
||||
from .model import CombinatorType, Selector, SelectorSet
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..dom import DOMNode
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
import rich.repr
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from enum import Enum
|
||||
from typing import Iterable, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Iterable
|
||||
|
||||
import rich.repr
|
||||
|
||||
from .styles import Styles
|
||||
from .tokenize import Token
|
||||
|
||||
@@ -2,23 +2,23 @@ from __future__ import annotations
|
||||
|
||||
from functools import lru_cache
|
||||
from pathlib import PurePath
|
||||
from typing import Iterator, Iterable, NoReturn
|
||||
from typing import Iterable, Iterator, NoReturn
|
||||
|
||||
from ..suggestions import get_suggestion
|
||||
from ._styles_builder import DeclarationError, StylesBuilder
|
||||
from .errors import UnresolvedVariableError
|
||||
from .types import Specificity3
|
||||
from ._styles_builder import StylesBuilder, DeclarationError
|
||||
from .model import (
|
||||
CombinatorType,
|
||||
Declaration,
|
||||
RuleSet,
|
||||
Selector,
|
||||
CombinatorType,
|
||||
SelectorSet,
|
||||
SelectorType,
|
||||
)
|
||||
from .styles import Styles
|
||||
from ..suggestions import get_suggestion
|
||||
from .tokenize import tokenize, tokenize_declarations, Token, tokenize_values
|
||||
from .tokenize import Token, tokenize, tokenize_declarations, tokenize_values
|
||||
from .tokenizer import EOFError, ReferencedBy
|
||||
from .types import Specificity3
|
||||
|
||||
SELECTOR_MAP: dict[str, tuple[SelectorType, Specificity3]] = {
|
||||
"selector": (SelectorType.TYPE, (0, 0, 1)),
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from enum import Enum, unique
|
||||
from fractions import Fraction
|
||||
from functools import lru_cache
|
||||
import re
|
||||
from typing import Iterable, NamedTuple
|
||||
|
||||
import rich.repr
|
||||
|
||||
@@ -2,15 +2,12 @@ from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from .scalar import ScalarOffset, Scalar
|
||||
from .._animator import Animation
|
||||
from .._animator import EasingFunction
|
||||
from .._animator import Animation, EasingFunction
|
||||
from .._types import CallbackType
|
||||
|
||||
from .scalar import Scalar, ScalarOffset
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..dom import DOMNode
|
||||
|
||||
from .styles import StylesBase
|
||||
|
||||
|
||||
|
||||
@@ -4,8 +4,7 @@ from abc import ABC, abstractmethod
|
||||
from dataclasses import dataclass, field
|
||||
from functools import lru_cache
|
||||
from operator import attrgetter
|
||||
from typing import Iterable, cast
|
||||
from typing import TYPE_CHECKING, Any, NamedTuple
|
||||
from typing import TYPE_CHECKING, Any, Iterable, NamedTuple, cast
|
||||
|
||||
import rich.repr
|
||||
from rich.style import Style
|
||||
|
||||
@@ -4,7 +4,7 @@ import re
|
||||
from pathlib import PurePath
|
||||
from typing import Iterable
|
||||
|
||||
from textual.css.tokenizer import Expect, Tokenizer, Token
|
||||
from textual.css.tokenizer import Expect, Token, Tokenizer
|
||||
|
||||
PERCENT = r"-?\d+\.?\d*%"
|
||||
DECIMAL = r"-?\d+\.?\d*"
|
||||
|
||||
@@ -4,11 +4,11 @@ import re
|
||||
from pathlib import PurePath
|
||||
from typing import NamedTuple
|
||||
|
||||
import rich.repr
|
||||
from rich.console import Group, RenderableType
|
||||
from rich.highlighter import ReprHighlighter
|
||||
from rich.padding import Padding
|
||||
from rich.panel import Panel
|
||||
import rich.repr
|
||||
from rich.syntax import Syntax
|
||||
from rich.text import Text
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Tuple
|
||||
|
||||
from typing_extensions import Literal
|
||||
|
||||
from ..color import Color
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from importlib_metadata import version
|
||||
from pathlib import Path
|
||||
|
||||
from importlib_metadata import version
|
||||
from rich import box
|
||||
from rich.console import RenderableType
|
||||
from rich.json import JSON
|
||||
|
||||
@@ -7,8 +7,7 @@ from rich.padding import Padding
|
||||
from rich.table import Table
|
||||
from rich.text import Text
|
||||
|
||||
from .color import Color, WHITE
|
||||
|
||||
from .color import WHITE, Color
|
||||
|
||||
NUMBER_OF_SHADES = 3
|
||||
|
||||
|
||||
@@ -9,21 +9,14 @@ from io import StringIO
|
||||
from time import time
|
||||
from typing import Any, NamedTuple, Type
|
||||
|
||||
import aiohttp
|
||||
import msgpack
|
||||
from aiohttp import ClientConnectorError, ClientResponseError, ClientWebSocketResponse
|
||||
from rich.console import Console
|
||||
from rich.segment import Segment
|
||||
|
||||
from .._log import LogGroup, LogVerbosity
|
||||
|
||||
|
||||
import aiohttp
|
||||
import msgpack
|
||||
from aiohttp import (
|
||||
ClientConnectorError,
|
||||
ClientResponseError,
|
||||
ClientWebSocketResponse,
|
||||
)
|
||||
|
||||
|
||||
DEVTOOLS_PORT = 8081
|
||||
WEBSOCKET_CONNECT_TIMEOUT = 3
|
||||
LOG_QUEUE_MAXSIZE = 512
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import inspect
|
||||
|
||||
from typing import TYPE_CHECKING, cast
|
||||
from .client import DevtoolsLog
|
||||
|
||||
from .._log import LogGroup, LogVerbosity
|
||||
from .client import DevtoolsLog
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .client import DevtoolsClient
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
|
||||
from aiohttp.web import run_app
|
||||
from aiohttp.web_app import Application
|
||||
from aiohttp.web_request import Request
|
||||
|
||||
@@ -7,19 +7,19 @@ import pickle
|
||||
from json import JSONDecodeError
|
||||
from typing import Any, cast
|
||||
|
||||
import msgpack
|
||||
from aiohttp import WSMessage, WSMsgType
|
||||
from aiohttp.abc import Request
|
||||
from aiohttp.web_ws import WebSocketResponse
|
||||
from rich.console import Console
|
||||
from rich.markup import escape
|
||||
import msgpack
|
||||
|
||||
from textual._log import LogGroup
|
||||
from textual._time import time
|
||||
from textual.devtools.renderables import (
|
||||
DevConsoleHeader,
|
||||
DevConsoleLog,
|
||||
DevConsoleNotice,
|
||||
DevConsoleHeader,
|
||||
)
|
||||
|
||||
QUEUEABLE_TYPES = {"client_log", "client_spillover"}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
|
||||
from .. import events
|
||||
from ..driver import Driver
|
||||
from ..geometry import Size
|
||||
from .. import events
|
||||
|
||||
|
||||
class HeadlessDriver(Driver):
|
||||
|
||||
@@ -2,27 +2,26 @@ from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
from codecs import getincrementaldecoder
|
||||
import selectors
|
||||
import signal
|
||||
import sys
|
||||
import termios
|
||||
import tty
|
||||
from typing import Any, TYPE_CHECKING
|
||||
from codecs import getincrementaldecoder
|
||||
from threading import Event, Thread
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from rich.console import Console
|
||||
|
||||
import rich.repr
|
||||
|
||||
from .. import log
|
||||
from ..driver import Driver
|
||||
from ..geometry import Size
|
||||
from .. import events, log
|
||||
from .._profile import timer
|
||||
from .._types import MessageTarget
|
||||
from .._xterm_parser import XTermParser
|
||||
from .._profile import timer
|
||||
from .. import events
|
||||
from ..driver import Driver
|
||||
from ..geometry import Size
|
||||
|
||||
|
||||
@rich.repr.auto
|
||||
|
||||
@@ -9,6 +9,7 @@ from __future__ import annotations
|
||||
from functools import lru_cache
|
||||
from operator import attrgetter, itemgetter
|
||||
from typing import (
|
||||
TYPE_CHECKING,
|
||||
Any,
|
||||
Collection,
|
||||
NamedTuple,
|
||||
@@ -16,7 +17,6 @@ from typing import (
|
||||
TypeVar,
|
||||
Union,
|
||||
cast,
|
||||
TYPE_CHECKING,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .._layout import Layout
|
||||
from .horizontal import HorizontalLayout
|
||||
from .grid import GridLayout
|
||||
from .horizontal import HorizontalLayout
|
||||
from .vertical import VerticalLayout
|
||||
|
||||
LAYOUT_MAP: dict[str, type[Layout]] = {
|
||||
|
||||
@@ -2,9 +2,9 @@ from __future__ import annotations
|
||||
|
||||
from fractions import Fraction
|
||||
|
||||
from .._resolve import resolve_box_models
|
||||
from ..geometry import Size, Region
|
||||
from .._layout import ArrangeResult, Layout, WidgetPlacement
|
||||
from .._resolve import resolve_box_models
|
||||
from ..geometry import Region, Size
|
||||
from ..widget import Widget
|
||||
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ from __future__ import annotations
|
||||
from fractions import Fraction
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from .._layout import ArrangeResult, Layout, WidgetPlacement
|
||||
from .._resolve import resolve_box_models
|
||||
from ..geometry import Region, Size
|
||||
from .._layout import ArrangeResult, Layout, WidgetPlacement
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..widget import Widget
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import ClassVar, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, ClassVar
|
||||
|
||||
import rich.repr
|
||||
|
||||
from . import _clock
|
||||
from .case import camel_to_snake
|
||||
from ._types import MessageTarget as MessageTarget
|
||||
from .case import camel_to_snake
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .widget import Widget
|
||||
from .message_pump import MessagePump
|
||||
from .widget import Widget
|
||||
|
||||
|
||||
@rich.repr.auto
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import rich.repr
|
||||
|
||||
from .geometry import Region
|
||||
from ._types import CallbackType
|
||||
from .geometry import Region
|
||||
from .message import Message
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .message_pump import MessagePump
|
||||
from .widget import Widget
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import rich.repr
|
||||
|
||||
import asyncio
|
||||
from typing import Generic
|
||||
|
||||
from .app import App, ReturnType
|
||||
import rich.repr
|
||||
|
||||
from ._wait import wait_for_idle
|
||||
from .app import App, ReturnType
|
||||
|
||||
|
||||
@rich.repr.auto(angular=True)
|
||||
|
||||
@@ -17,7 +17,7 @@ import rich.repr
|
||||
|
||||
from . import events
|
||||
from ._callback import count_parameters
|
||||
from ._types import MessageTarget, CallbackType
|
||||
from ._types import CallbackType, MessageTarget
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .dom import DOMNode
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from rich.console import ConsoleOptions, Console, RenderResult
|
||||
from rich.console import Console, ConsoleOptions, RenderResult
|
||||
from rich.segment import Segment
|
||||
from rich.style import Style
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from rich.console import ConsoleOptions, Console, RenderResult
|
||||
|
||||
from rich.console import Console, ConsoleOptions, RenderResult
|
||||
from rich.segment import Segment
|
||||
from rich.style import Style
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import statistics
|
||||
from typing import Generic, Sequence, Iterable, Callable, TypeVar
|
||||
from typing import Callable, Generic, Iterable, Sequence, TypeVar
|
||||
|
||||
from rich.color import Color
|
||||
from rich.console import ConsoleOptions, Console, RenderResult
|
||||
from rich.console import Console, ConsoleOptions, RenderResult
|
||||
from rich.segment import Segment
|
||||
from rich.style import Style
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ from typing import Iterable, Tuple, cast
|
||||
|
||||
from rich.cells import cell_len
|
||||
from rich.color import Color
|
||||
from rich.console import ConsoleOptions, Console, RenderResult, RenderableType
|
||||
from rich.console import Console, ConsoleOptions, RenderableType, RenderResult
|
||||
from rich.segment import Segment
|
||||
from rich.style import Style
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import Iterable
|
||||
|
||||
from rich.console import ConsoleOptions, Console, RenderResult, RenderableType
|
||||
from rich.console import Console, ConsoleOptions, RenderableType, RenderResult
|
||||
from rich.segment import Segment
|
||||
from rich.style import Style
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from rich.console import ConsoleOptions, Console, RenderResult
|
||||
from rich.console import Console, ConsoleOptions, RenderResult
|
||||
from rich.style import StyleType
|
||||
from rich.text import Text
|
||||
|
||||
@@ -99,6 +99,7 @@ class UnderlineBar:
|
||||
if __name__ == "__main__":
|
||||
import random
|
||||
from time import sleep
|
||||
|
||||
from rich.color import ANSI_COLOR_NAMES
|
||||
|
||||
console = Console()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Iterable, Iterator, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Iterable, Iterator
|
||||
|
||||
import rich.repr
|
||||
from rich.console import RenderableType
|
||||
@@ -9,14 +9,14 @@ from rich.style import Style
|
||||
from . import errors, events, messages
|
||||
from ._callback import invoke
|
||||
from ._compositor import Compositor, MapGeometry
|
||||
from ._types import CallbackType
|
||||
from .css.match import match
|
||||
from .css.parse import parse_selectors
|
||||
from .dom import DOMNode
|
||||
from .timer import Timer
|
||||
from ._types import CallbackType
|
||||
from .geometry import Offset, Region, Size
|
||||
from .reactive import Reactive
|
||||
from .renderables.blank import Blank
|
||||
from .timer import Timer
|
||||
from .widget import Widget
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections import deque
|
||||
from typing import Iterable, Iterator, TypeVar, overload, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Iterable, Iterator, TypeVar, overload
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from textual.dom import DOMNode
|
||||
|
||||
@@ -35,9 +35,9 @@ from rich.text import Text
|
||||
from rich.traceback import Traceback
|
||||
|
||||
from . import errors, events, messages
|
||||
from ._asyncio import create_task
|
||||
from ._animator import DEFAULT_EASING, Animatable, BoundAnimator, EasingFunction
|
||||
from ._arrange import DockArrangeResult, arrange
|
||||
from ._asyncio import create_task
|
||||
from ._context import active_app
|
||||
from ._easing import DEFAULT_SCROLL_EASING
|
||||
from ._layout import Layout
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
from importlib import import_module
|
||||
|
||||
import typing
|
||||
from importlib import import_module
|
||||
|
||||
from ..case import camel_to_snake
|
||||
|
||||
@@ -8,6 +9,7 @@ from ..case import camel_to_snake
|
||||
# but also to the `__init__.pyi` file in this same folder - otherwise text editors and type checkers won't
|
||||
# be able to "see" them.
|
||||
if typing.TYPE_CHECKING:
|
||||
from ..widget import Widget
|
||||
from ._button import Button
|
||||
from ._data_table import DataTable
|
||||
from ._directory_tree import DirectoryTree
|
||||
@@ -24,7 +26,6 @@ if typing.TYPE_CHECKING:
|
||||
from ._text_log import TextLog
|
||||
from ._tree import Tree
|
||||
from ._welcome import Welcome
|
||||
from ..widget import Widget
|
||||
|
||||
|
||||
__all__ = [
|
||||
|
||||
@@ -6,8 +6,8 @@ from ._footer import Footer as Footer
|
||||
from ._header import Header as Header
|
||||
from ._input import Input as Input
|
||||
from ._label import Label as Label
|
||||
from ._list_view import ListView as ListView
|
||||
from ._list_item import ListItem as ListItem
|
||||
from ._list_view import ListView as ListView
|
||||
from ._placeholder import Placeholder as Placeholder
|
||||
from ._pretty import Pretty as Pretty
|
||||
from ._static import Static as Static
|
||||
|
||||
@@ -2,11 +2,11 @@ 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
|
||||
from rich.text import Text, TextType
|
||||
from typing_extensions import Literal
|
||||
|
||||
from .. import events
|
||||
from ..css._error_tools import friendly_list
|
||||
@@ -14,7 +14,6 @@ from ..message import Message
|
||||
from ..reactive import reactive
|
||||
from ..widgets import Static
|
||||
|
||||
|
||||
ButtonVariant = Literal["default", "primary", "success", "warning", "error"]
|
||||
_VALID_BUTTON_VARIANTS = {"default", "primary", "success", "warning", "error"}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ from __future__ import annotations
|
||||
from dataclasses import dataclass, field
|
||||
from itertools import chain, zip_longest
|
||||
from typing import Generic, Iterable, cast
|
||||
from typing_extensions import ClassVar, TypeVar, Literal
|
||||
|
||||
import rich.repr
|
||||
from rich.console import RenderableType
|
||||
@@ -12,6 +11,7 @@ from rich.protocol import is_renderable
|
||||
from rich.segment import Segment
|
||||
from rich.style import Style
|
||||
from rich.text import Text, TextType
|
||||
from typing_extensions import ClassVar, Literal, TypeVar
|
||||
|
||||
from .. import events, messages
|
||||
from .._cache import LRUCache
|
||||
|
||||
@@ -7,9 +7,9 @@ from typing import ClassVar
|
||||
from rich.style import Style
|
||||
from rich.text import Text, TextType
|
||||
|
||||
from ..message import Message
|
||||
from ._tree import Tree, TreeNode, TOGGLE_STYLE
|
||||
from .._types import MessageTarget
|
||||
from ..message import Message
|
||||
from ._tree import TOGGLE_STYLE, Tree, TreeNode
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
@@ -4,8 +4,8 @@ from datetime import datetime
|
||||
|
||||
from rich.text import Text
|
||||
|
||||
from ..widget import Widget
|
||||
from ..reactive import Reactive
|
||||
from ..widget import Widget
|
||||
|
||||
|
||||
class HeaderIcon(Widget):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from __future__ import annotations
|
||||
from typing import ClassVar
|
||||
|
||||
import re
|
||||
from typing import ClassVar
|
||||
|
||||
from rich.cells import cell_len, get_character_cell_size
|
||||
from rich.console import Console, ConsoleOptions, RenderableType, RenderResult
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import ClassVar
|
||||
|
||||
from textual.await_remove import AwaitRemove
|
||||
|
||||
@@ -7,8 +7,7 @@ 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 ..widget import RenderResult, Widget
|
||||
|
||||
PlaceholderVariant = Literal["default", "size", "text"]
|
||||
_VALID_PLACEHOLDER_VARIANTS_ORDERED: list[PlaceholderVariant] = [
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from rich.pretty import Pretty as PrettyRenderable
|
||||
|
||||
from ..widget import Widget
|
||||
|
||||
@@ -8,8 +8,8 @@ from ..binding import Binding, BindingType
|
||||
from ..geometry import Size
|
||||
from ..message import Message
|
||||
from ..reactive import reactive
|
||||
from ..widget import Widget
|
||||
from ..scrollbar import ScrollBarRender
|
||||
from ..widget import Widget
|
||||
|
||||
|
||||
class Switch(Widget, can_focus=True):
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from ..app import ComposeResult
|
||||
from ._static import Static
|
||||
from ._button import Button
|
||||
from ..containers import Container
|
||||
|
||||
from rich.markdown import Markdown
|
||||
|
||||
from ..app import ComposeResult
|
||||
from ..containers import Container
|
||||
from ._button import Button
|
||||
from ._static import Static
|
||||
|
||||
WELCOME_MD = """\
|
||||
# Welcome!
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ from typing import Iterable
|
||||
from rich.cells import cell_len
|
||||
from rich.console import Console, ConsoleOptions, RenderableType, RenderResult
|
||||
from rich.segment import Segment
|
||||
from rich.style import StyleType, Style
|
||||
from rich.style import Style, StyleType
|
||||
from rich.text import Text
|
||||
|
||||
from textual import events
|
||||
from textual._layout_resolve import layout_resolve, Edge
|
||||
from textual._layout_resolve import Edge, layout_resolve
|
||||
from textual.keys import Keys
|
||||
from textual.reactive import Reactive
|
||||
from textual.renderables.text_opacity import TextOpacity
|
||||
|
||||
@@ -2,17 +2,17 @@ import pytest
|
||||
|
||||
from tests.utilities.render import render
|
||||
from textual.css._help_text import (
|
||||
spacing_wrong_number_of_values_help_text,
|
||||
spacing_invalid_value_help_text,
|
||||
scalar_help_text,
|
||||
string_enum_help_text,
|
||||
color_property_help_text,
|
||||
border_property_help_text,
|
||||
layout_property_help_text,
|
||||
fractional_property_help_text,
|
||||
offset_property_help_text,
|
||||
align_help_text,
|
||||
border_property_help_text,
|
||||
color_property_help_text,
|
||||
fractional_property_help_text,
|
||||
layout_property_help_text,
|
||||
offset_property_help_text,
|
||||
offset_single_axis_help_text,
|
||||
scalar_help_text,
|
||||
spacing_invalid_value_help_text,
|
||||
spacing_wrong_number_of_values_help_text,
|
||||
string_enum_help_text,
|
||||
style_flags_property_help_text,
|
||||
)
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ from textual.css.parse import substitute_references
|
||||
from textual.css.scalar import Scalar, Unit
|
||||
from textual.css.stylesheet import Stylesheet, StylesheetParseError
|
||||
from textual.css.tokenize import tokenize
|
||||
from textual.css.tokenizer import Token, ReferencedBy
|
||||
from textual.css.tokenizer import ReferencedBy, Token
|
||||
from textual.css.transition import Transition
|
||||
from textual.geometry import Spacing
|
||||
from textual.layouts.vertical import VerticalLayout
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
from decimal import Decimal
|
||||
|
||||
import pytest
|
||||
|
||||
from rich.style import Style
|
||||
|
||||
from textual.color import Color
|
||||
from textual.css.errors import StyleValueError
|
||||
from textual.css.scalar import Scalar, Unit
|
||||
from textual.css.styles import Styles, RenderStyles
|
||||
from textual.css.styles import RenderStyles, Styles
|
||||
from textual.dom import DOMNode
|
||||
from textual.widget import Widget
|
||||
|
||||
|
||||
@@ -11,6 +11,4 @@ _WINDOWS = sys.platform == "win32"
|
||||
# and the error messages suggest the event loop is being shutdown before async fixture
|
||||
# teardown code has finished running. These are very rare, but are much more of an issue on
|
||||
# CI since they can delay builds that have passed locally.
|
||||
pytestmark = pytest.mark.skipif(
|
||||
_MACOS_CI or _WINDOWS, reason="Issue #411"
|
||||
)
|
||||
pytestmark = pytest.mark.skipif(_MACOS_CI or _WINDOWS, reason="Issue #411")
|
||||
|
||||
@@ -30,7 +30,6 @@ async def test_devtools_client_is_connected(devtools):
|
||||
|
||||
@time_machine.travel(datetime.utcfromtimestamp(TIMESTAMP))
|
||||
async def test_devtools_log_places_encodes_and_queues_message(devtools):
|
||||
|
||||
await devtools._stop_log_queue_processing()
|
||||
devtools.log(DevtoolsLog("Hello, world!", CALLER))
|
||||
queued_log = await devtools.log_queue.get()
|
||||
|
||||
@@ -5,7 +5,6 @@ from __future__ import annotations
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.widgets import Input
|
||||
|
||||
|
||||
TEST_INPUTS: dict[str | None, str] = {
|
||||
"empty": "",
|
||||
"multi-no-punctuation": "Curse your sudden but inevitable betrayal",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from rich.console import Console
|
||||
|
||||
from textual.app import App
|
||||
from textual.widgets import Input
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user