Only import ReferenceType when type checking
This commit is contained in:
parent
a352804c14
commit
f6a1eb19d7
@ -7,7 +7,6 @@ from string import Formatter as StringFormatter
|
|||||||
from typing import (
|
from typing import (
|
||||||
Any, Callable, Dict, List, NamedTuple, Optional, Sequence, Tuple, Union, TYPE_CHECKING
|
Any, Callable, Dict, List, NamedTuple, Optional, Sequence, Tuple, Union, TYPE_CHECKING
|
||||||
)
|
)
|
||||||
from weakref import ReferenceType
|
|
||||||
|
|
||||||
from .borders import Border, BorderColor
|
from .borders import Border, BorderColor
|
||||||
from .config import build_ansi_color_table
|
from .config import build_ansi_color_table
|
||||||
@ -23,6 +22,7 @@ from .utils import color_as_int, log_error, sgr_sanitizer_pat
|
|||||||
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
from weakref import ReferenceType
|
||||||
from .tabs import Tab
|
from .tabs import Tab
|
||||||
|
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ class TabBarData(NamedTuple):
|
|||||||
title: str
|
title: str
|
||||||
is_active: bool
|
is_active: bool
|
||||||
needs_attention: bool
|
needs_attention: bool
|
||||||
tab_ref: "ReferenceType['Tab']"
|
tab_ref: 'ReferenceType[Tab]'
|
||||||
num_windows: int
|
num_windows: int
|
||||||
num_window_groups: int
|
num_window_groups: int
|
||||||
layout_name: str
|
layout_name: str
|
||||||
@ -180,7 +180,7 @@ def template_has_field(template: str, field: str) -> bool:
|
|||||||
|
|
||||||
class TabCWD:
|
class TabCWD:
|
||||||
|
|
||||||
def __init__(self, tab_ref: "ReferenceType['Tab']"):
|
def __init__(self, tab_ref: 'ReferenceType[Tab]'):
|
||||||
self.tab_ref = tab_ref
|
self.tab_ref = tab_ref
|
||||||
self.saved_val: Optional[str] = None
|
self.saved_val: Optional[str] = None
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user