Skip to content

Commit

Permalink
Use typing-extensions on py<3.8
Browse files Browse the repository at this point in the history
typing-extensions backport typing features from Python 3.8.  Use
built-in typing module in Python 3.8 and newer.
  • Loading branch information
mgorny committed Apr 24, 2021
1 parent 5b666af commit 43590b7
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 7 deletions.
6 changes: 5 additions & 1 deletion examples/top_lite_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
from rich.console import Console
from rich.live import Live
from rich.table import Table
from typing_extensions import Literal

try:
from typing import Literal
except ImportError:
from typing_extensions import Literal


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ include = ["rich/py.typed"]

[tool.poetry.dependencies]
python = "^3.6"
typing-extensions = "^3.7.4"
typing-extensions = {version = "^3.7.4", python = "<3.8"}
dataclasses = {version=">=0.7,<0.9", python = "~3.6"}
pygments = "^2.6.0"
commonmark = "^0.9.0"
Expand Down
6 changes: 5 additions & 1 deletion rich/_ratio.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from fractions import Fraction
from math import ceil, floor, modf
from typing import cast, List, Optional, Sequence
from typing_extensions import Protocol

try:
from typing import Protocol
except ImportError:
from typing_extensions import Protocol


class Edge(Protocol):
Expand Down
6 changes: 5 additions & 1 deletion rich/align.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from itertools import chain
from typing import Iterable, Optional, TYPE_CHECKING

from typing_extensions import Literal
try:
from typing import Literal
except ImportError:
from typing_extensions import Literal

from .constrain import Constrain
from .jupyter import JupyterMixin
from .measure import Measurement
Expand Down
5 changes: 4 additions & 1 deletion rich/box.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from typing import TYPE_CHECKING, Iterable, List

from typing_extensions import Literal
try:
from typing import Literal
except ImportError:
from typing_extensions import Literal

from ._loop import loop_last

Expand Down
5 changes: 4 additions & 1 deletion rich/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
cast,
)

from typing_extensions import Literal, Protocol, runtime_checkable
try:
from typing import Literal, Protocol, runtime_checkable
except ImportError:
from typing_extensions import Literal, Protocol, runtime_checkable

from . import errors, themes
from ._emoji_replace import _emoji_replace
Expand Down
5 changes: 4 additions & 1 deletion rich/live_render.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from threading import RLock
from typing import Optional, Tuple

from typing_extensions import Literal
try:
from typing import Literal
except ImportError:
from typing_extensions import Literal

from ._loop import loop_last
from .console import Console, ConsoleOptions, RenderableType, RenderResult
Expand Down

0 comments on commit 43590b7

Please sign in to comment.