mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Added module level getattr to get version
This commit is contained in:
@@ -1,22 +1,33 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import inspect
|
||||
from typing import Callable
|
||||
|
||||
import rich.repr
|
||||
from rich.console import RenderableType
|
||||
|
||||
__all__ = ["log", "panic"]
|
||||
|
||||
|
||||
from ._context import active_app
|
||||
from ._log import LogGroup, LogVerbosity
|
||||
from ._typing import TypeAlias
|
||||
|
||||
__all__ = ["log", "panic"]
|
||||
|
||||
|
||||
LogCallable: TypeAlias = "Callable"
|
||||
|
||||
|
||||
def __getattr__(name: str) -> str:
|
||||
if name == "__version__":
|
||||
try:
|
||||
from importlib.metadata import version
|
||||
except ImportError:
|
||||
import pkg_resources
|
||||
|
||||
return pkg_resources.get_distribution("textual").version
|
||||
else:
|
||||
return version("textual")
|
||||
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
||||
|
||||
|
||||
class LoggerError(Exception):
|
||||
"""Raised when the logger failed."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user