From 7bce33140fe7e7c65d59188ed4fdefa6416e4096 Mon Sep 17 00:00:00 2001 From: Robson Roberto Souza Peixoto Date: Fri, 12 May 2023 14:24:13 -0300 Subject: [PATCH 1/2] Add missing python version 3.7 on test matrix --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3bc01d65fb0..2f92f9fad30 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,7 +26,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10", "3.11",] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11",] os: [ubuntu-latest, macOS-latest, windows-latest] steps: From a84870a836e5f442cb65edea0610128f09e425be Mon Sep 17 00:00:00 2001 From: Robson Roberto Souza Peixoto Date: Fri, 12 May 2023 15:07:57 -0300 Subject: [PATCH 2/2] Literal type only exists on Python >= 3.8 --- src/pyink/ink.py | 9 ++++++++- src/pyink/linegen.py | 7 ++++++- src/pyink/mode.py | 6 +++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/pyink/ink.py b/src/pyink/ink.py index 0e679eddaef..aa5c9899e37 100644 --- a/src/pyink/ink.py +++ b/src/pyink/ink.py @@ -3,10 +3,10 @@ This is a separate module for easier patch management. """ +import sys from typing import ( Collection, List, - Literal, Optional, Sequence, Set, @@ -14,6 +14,13 @@ Union, Iterator, ) + + +if sys.version_info < (3, 8): + from typing_extensions import Literal +else: + from typing import Literal + from blib2to3.pgen2.token import ASYNC, NEWLINE, STRING from blib2to3.pytree import type_repr from pyink.mode import Quote diff --git a/src/pyink/linegen.py b/src/pyink/linegen.py index f3de78ce725..76a2e4f78e2 100644 --- a/src/pyink/linegen.py +++ b/src/pyink/linegen.py @@ -5,7 +5,12 @@ from dataclasses import replace from enum import Enum, auto from functools import partial, wraps -from typing import Collection, Iterator, List, Literal, Optional, Set, Union, cast +from typing import Collection, Iterator, List, Optional, Set, Union, cast + +if sys.version_info < (3, 8): + from typing_extensions import Final, Literal +else: + from typing import Final, Literal from pyink.brackets import ( COMMA_PRIORITY, diff --git a/src/pyink/mode.py b/src/pyink/mode.py index 43bfbc5fcdb..ff962938359 100644 --- a/src/pyink/mode.py +++ b/src/pyink/mode.py @@ -9,13 +9,13 @@ from enum import Enum, auto from hashlib import sha256 from operator import attrgetter -from typing import Dict, Literal, Set +from typing import Dict, Set from warnings import warn if sys.version_info < (3, 8): - from typing_extensions import Final + from typing_extensions import Final, Literal else: - from typing import Final + from typing import Final, Literal from pyink.const import DEFAULT_LINE_LENGTH