remove try catch for type_extensions and replace with if sys.version_info

This commit is contained in:
Nathan Page 2021-05-09 15:56:04 -07:00
parent fdb371d1bb
commit b9ad6ba65d
4 changed files with 18 additions and 17 deletions

View File

@ -1,7 +1,7 @@
"""Lite simulation of the top linux command."""
import datetime
import random
import sys
import time
from dataclasses import dataclass
@ -10,10 +10,10 @@ from rich.console import Console
from rich.live import Live
from rich.table import Table
try:
from typing_extensions import Literal
except ImportError:
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
@dataclass

View File

@ -1,10 +1,11 @@
import sys
from itertools import chain
from typing import Iterable, Optional, TYPE_CHECKING
from typing import TYPE_CHECKING, Iterable, Optional
try:
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
except ImportError: # pragma: no cover
from typing import Literal # type: ignore
from .constrain import Constrain
from .jupyter import JupyterMixin
@ -12,9 +13,8 @@ from .measure import Measurement
from .segment import Segment
from .style import StyleType
if TYPE_CHECKING:
from .console import Console, ConsoleOptions, RenderResult, RenderableType
from .console import Console, ConsoleOptions, RenderableType, RenderResult
AlignMethod = Literal["left", "center", "right"]
VerticalAlignMethod = Literal["top", "middle", "bottom"]

View File

@ -1,9 +1,10 @@
import sys
from typing import TYPE_CHECKING, Iterable, List
try:
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
except ImportError: # pragma: no cover
from typing import Literal # type: ignore
from ._loop import loop_last

View File

@ -1,10 +1,10 @@
from threading import RLock
import sys
from typing import Optional, Tuple
try:
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
except ImportError: # pragma: no cover
from typing import Literal # type: ignore
from ._loop import loop_last