Skip to content

Commit b9107d8

Browse files
authored
Merge pull request #98 from aphedges/install-typing_extensions
Install `typing_extensions` if needed
2 parents 7f6dcca + 314520c commit b9107d8

File tree

8 files changed

+67
-23
lines changed

8 files changed

+67
-23
lines changed

.github/workflows/test-pr.yml

+28-5
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,43 @@ name: test-pr
33
on:
44
pull_request:
55
branches:
6-
- "main"
6+
- main
7+
push:
8+
branches:
9+
- main
10+
- test-ci**
11+
workflow_dispatch: # Enable workflow to be run manually
12+
13+
# Disable all access to the GitHub API by default
14+
# This default can be overridden for individual workflows and jobs
15+
# Documentation: https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#permissions
16+
permissions: {}
17+
18+
# Cancel the currently running CI job if you push a change while CI is running
19+
# Documentation: https://docs.github.com/en/actions/using-jobs/using-concurrency
20+
concurrency:
21+
group: ${{ github.workflow }}-${{ github.ref }}
22+
cancel-in-progress: true
723

824
jobs:
925
test:
10-
runs-on: ubuntu-latest
26+
runs-on: ubuntu-22.04 # Needed for Python 3.7
27+
name: Run tests
28+
env:
29+
PYTHON_VERSION: 3.7.17
30+
defaults:
31+
run:
32+
shell: bash -leo pipefail {0}
1133
steps:
1234
- name: Checkout repository
13-
uses: actions/checkout@v2
35+
uses: actions/checkout@v4
1436
- name: Set Up Python
15-
uses: actions/setup-python@v2
37+
uses: actions/setup-python@v5
1638
with:
17-
python-version: "3.7"
39+
python-version: ${{ env.PYTHON_VERSION }}
1840
- name: Install daidepp
1941
run: |
42+
pip install -U pip
2043
pip install -e .[dev]
2144
- name: Test
2245
run: |

setup.cfg

+12-11
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,24 @@ python_requires = >=3.7
1515
install_requires =
1616
parsimonious==0.9.0
1717
importlib-metadata>=1.4.0 ; python_version < "3.8"
18+
typing_extensions>=3.10.0.0 ; python_version < "3.8"
1819

1920
[options.packages.find]
2021
where = src
2122

2223
[options.extras_require]
2324
dev =
24-
black>=22.8.0
25-
docformatter==1.4
26-
isort>=5.10.1
27-
pydocstyle==6.1.1
28-
pylint==2.12.2
29-
pytest==7.0.0
30-
pytest-black==0.3.12
31-
pytest-cov==3.0.0
32-
pytest-dependency==0.5.1
33-
pytest-mypy==0.9.1
34-
pytest-timeout==2.1.0
25+
black==23.3.0
26+
docformatter==1.7.5
27+
isort==5.11.5
28+
pydocstyle==6.3.0
29+
pylint==2.17.7
30+
pytest==7.4.4
31+
pytest-black==0.6.0
32+
pytest-cov==4.1.0
33+
pytest-dependency==0.6.0
34+
pytest-mypy==0.10.3
35+
pytest-timeout==2.3.1
3536

3637
[isort]
3738
multi_line_output = 3

src/daidepp/constants.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
from typing_extensions import Literal
1+
try:
2+
from typing import Literal
3+
except ImportError:
4+
from typing_extensions import Literal
25

36
Power = Literal["AUS", "ENG", "FRA", "GER", "ITA", "RUS", "TUR"]
47
UnitType = Literal["AMY", "FLT"]

src/daidepp/grammar/grammar.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
from __future__ import annotations
66

77
from typing import Dict, Tuple
8-
from typing_extensions import get_args
98

10-
from typing_extensions import Literal
9+
try:
10+
from typing import Literal, get_args
11+
except ImportError:
12+
from typing_extensions import Literal, get_args
1113

1214
DAIDELevel = Literal[
1315
0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160

src/daidepp/grammar/grammar_utils.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
from typing import Dict, List, Optional, Set, Tuple, Union
44

55
from parsimonious.grammar import Grammar
6-
from typing_extensions import Literal
6+
7+
try:
8+
from typing import Literal
9+
except ImportError:
10+
from typing_extensions import Literal
711

812
from daidepp.constants import PressKeywords
913
from daidepp.grammar.grammar import (

src/daidepp/keywords/base_keywords.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
from dataclasses import dataclass
44
from typing import Optional, Tuple, Union
55

6-
from typing_extensions import get_args
6+
try:
7+
from typing import get_args
8+
except ImportError:
9+
from typing_extensions import get_args
710

811
from daidepp.constants import *
912
from daidepp.keywords.daide_object import _DAIDEObject

src/daidepp/visitor.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
from typing import Any
33

44
from parsimonious.nodes import Node, NodeVisitor
5-
from typing_extensions import get_args
5+
6+
try:
7+
from typing import get_args
8+
except ImportError:
9+
from typing_extensions import get_args
610

711
from daidepp.constants import ProvinceNoCoast
812
from daidepp.keywords.base_keywords import *

tests/conftest.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import pytest
2-
from typing_extensions import get_args
2+
3+
try:
4+
from typing import get_args
5+
except ImportError:
6+
from typing_extensions import get_args
37

48
from daidepp.grammar import create_daide_grammar
59
from daidepp.grammar.grammar import DAIDELevel, MAX_DAIDE_LEVEL

0 commit comments

Comments
 (0)