Skip to content

Commit 20281dc

Browse files
committed
remove LiteralType from 3.8
1 parent 6c96eba commit 20281dc

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

.github/workflows/check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
with:
1919
python-version: ${{ matrix.python-version }}
2020
- name: Run image
21-
uses: abatilo/actions-poetry@v2
21+
uses: abatilo/actions-poetry@v2.1.6
2222
with:
2323
poetry-version: ${{ env.POETRY_VERSION }}
2424
- run: poetry config virtualenvs.in-project true

basedtyping/runtime_only.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99
from typing_extensions import Final as Final_ext
1010

11-
if sys.version_info >= (3, 8):
11+
if sys.version_info >= (3, 9):
12+
# Despite the fact that Literal is in 3.8, it is just a _GenericAlias,
13+
# so would be broken
1214
from typing import Final, Literal
1315

1416
LiteralType: Final = type(Literal[1])
Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
import sys
2+
from typing import Union
23

3-
if sys.version_info >= (3, 8):
4-
from typing import Literal, Union
4+
import pytest
5+
6+
7+
@pytest.mark.skipif(sys.version_info < (3, 9))
8+
def test_literal_type_positive() -> None:
9+
from typing import Literal
510

611
from basedtyping.runtime_only import LiteralType
712

8-
def test_literal_type_positive() -> None:
9-
assert isinstance(Literal[1, 2], LiteralType)
13+
assert isinstance(Literal[1, 2], LiteralType)
14+
15+
16+
@pytest.mark.skipif(sys.version_info < (3, 9))
17+
def test_literal_type_negative() -> None:
18+
from basedtyping.runtime_only import LiteralType
1019

11-
def test_literal_type_negative() -> None:
12-
assert not isinstance(Union[int, str], LiteralType)
20+
assert not isinstance(Union[int, str], LiteralType)

0 commit comments

Comments
 (0)