mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Use importlib-metadata backport for getting version
This commit is contained in:
2
poetry.lock
generated
2
poetry.lock
generated
@@ -764,7 +764,7 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "1.1"
|
lock-version = "1.1"
|
||||||
python-versions = "^3.7"
|
python-versions = "^3.7"
|
||||||
content-hash = "e7353ea5318ad3fa2943ee707f2c1930783c355bad6a28aec3d97c0b917b6dbf"
|
content-hash = "256c1d6571a11bf4b80d0eba16d9e39bf2965c4436281c3ec40033cca54aa098"
|
||||||
|
|
||||||
[metadata.files]
|
[metadata.files]
|
||||||
aiohttp = [
|
aiohttp = [
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ rich = "^12.0.0"
|
|||||||
#rich = {git = "git@github.com:willmcgugan/rich", rev = "link-id"}
|
#rich = {git = "git@github.com:willmcgugan/rich", rev = "link-id"}
|
||||||
typing-extensions = { version = "^3.10.0", python = "<3.8" }
|
typing-extensions = { version = "^3.10.0", python = "<3.8" }
|
||||||
click = "8.1.2"
|
click = "8.1.2"
|
||||||
|
importlib-metadata = "^4.11.3"
|
||||||
|
|
||||||
[tool.poetry.dev-dependencies]
|
[tool.poetry.dev-dependencies]
|
||||||
pytest = "^6.2.3"
|
pytest = "^6.2.3"
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import inspect
|
|||||||
from rich.console import RenderableType
|
from rich.console import RenderableType
|
||||||
|
|
||||||
__all__ = ["log", "panic"]
|
__all__ = ["log", "panic"]
|
||||||
__version__ = "0.1.15"
|
|
||||||
|
|
||||||
|
|
||||||
def log(*args: object, verbosity: int = 0, **kwargs) -> None:
|
def log(*args: object, verbosity: int = 0, **kwargs) -> None:
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import click
|
import click
|
||||||
|
from importlib_metadata import version
|
||||||
|
|
||||||
import textual
|
|
||||||
from textual.devtools.server import _run_devtools
|
from textual.devtools.server import _run_devtools
|
||||||
|
|
||||||
|
|
||||||
@click.group()
|
@click.group()
|
||||||
@click.version_option(textual.__version__)
|
@click.version_option(version("textual"))
|
||||||
def run():
|
def run():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,11 @@ from datetime import datetime, timezone
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Iterable
|
from typing import Iterable
|
||||||
|
|
||||||
|
from importlib_metadata import version
|
||||||
from rich.containers import Renderables
|
from rich.containers import Renderables
|
||||||
from rich.style import Style
|
from rich.style import Style
|
||||||
from rich.text import Text
|
from rich.text import Text
|
||||||
|
|
||||||
import textual
|
|
||||||
|
|
||||||
if sys.version_info >= (3, 8):
|
if sys.version_info >= (3, 8):
|
||||||
from typing import Literal
|
from typing import Literal
|
||||||
else:
|
else:
|
||||||
@@ -33,7 +32,7 @@ class DevConsoleHeader:
|
|||||||
) -> RenderResult:
|
) -> RenderResult:
|
||||||
lines = Renderables(
|
lines = Renderables(
|
||||||
[
|
[
|
||||||
f"[bold]Textual Development Console [#b169dd]v{textual.__version__}",
|
f"[bold]Textual Development Console [#b169dd]v{version('textual')}",
|
||||||
"[#967fa3]Run a Textual app with the environment variable [b]TEXTUAL_DEVTOOLS=1[/] to connect.",
|
"[#967fa3]Run a Textual app with the environment variable [b]TEXTUAL_DEVTOOLS=1[/] to connect.",
|
||||||
"[#967fa3]Press [b]Ctrl+C[/] to quit.",
|
"[#967fa3]Press [b]Ctrl+C[/] to quit.",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
from click.testing import CliRunner
|
from click.testing import CliRunner
|
||||||
|
from importlib_metadata import version
|
||||||
|
|
||||||
import textual
|
|
||||||
from textual.cli.cli import run
|
from textual.cli.cli import run
|
||||||
|
|
||||||
|
|
||||||
def test_cli_version():
|
def test_cli_version():
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
result = runner.invoke(run, ["--version"])
|
result = runner.invoke(run, ["--version"])
|
||||||
assert textual.__version__ in result.output, "You need to update __version__"
|
assert version("textual") in result.output
|
||||||
|
|||||||
Reference in New Issue
Block a user