typing of Final

This commit is contained in:
Will McGugan
2023-02-07 09:06:08 +00:00
parent af7fb9b02a
commit bcf382d2ff
3 changed files with 16 additions and 19 deletions

View File

@@ -1,25 +1,22 @@
"""Simple version of 5x5, developed for/with Textual.""" """Simple version of 5x5, developed for/with Textual."""
from pathlib import Path from pathlib import Path
from typing import cast from typing import TYPE_CHECKING, cast
import sys
if sys.version_info >= (3, 8):
from typing import Final
else:
from typing_extensions import Final
from textual.containers import Horizontal
from textual.app import App, ComposeResult
from textual.screen import Screen
from textual.widget import Widget
from textual.widgets import Footer, Button, Label
from textual.css.query import DOMQuery
from textual.reactive import reactive
from textual.binding import Binding
from rich.markdown import Markdown from rich.markdown import Markdown
from textual.app import App, ComposeResult
from textual.binding import Binding
from textual.containers import Horizontal
from textual.css.query import DOMQuery
from textual.reactive import reactive
from textual.screen import Screen
from textual.widget import Widget
from textual.widgets import Button, Footer, Label
if TYPE_CHECKING:
from typing import Final
class Help(Screen): class Help(Screen):
"""The help screen for the application.""" """The help screen for the application."""

View File

@@ -19,6 +19,5 @@ __all__ = [
"Literal", "Literal",
"Protocol", "Protocol",
"runtime_checkable", "runtime_checkable",
"TypeAlias",
"TypedDict", "TypedDict",
] ]

View File

@@ -1,6 +1,6 @@
from __future__ import annotations from __future__ import annotations
from typing import Iterable, Iterator from typing import Iterable, Iterator, TYPE_CHECKING
import rich.repr import rich.repr
from rich.console import RenderableType from rich.console import RenderableType
@@ -15,11 +15,12 @@ from .dom import DOMNode
from .timer import Timer from .timer import Timer
from ._types import CallbackType from ._types import CallbackType
from .geometry import Offset, Region, Size from .geometry import Offset, Region, Size
from ._typing import Final
from .reactive import Reactive from .reactive import Reactive
from .renderables.blank import Blank from .renderables.blank import Blank
from .widget import Widget from .widget import Widget
if TYPE_CHECKING:
from typing import Final
# Screen updates will be batched so that they don't happen more often than 120 times per second: # Screen updates will be batched so that they don't happen more often than 120 times per second:
UPDATE_PERIOD: Final[float] = 1 / 120 UPDATE_PERIOD: Final[float] = 1 / 120