Skip to content

Install typing_extensions if needed #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions .github/workflows/test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,43 @@ name: test-pr
on:
pull_request:
branches:
- "main"
- main
push:
branches:
- main
- test-ci**
workflow_dispatch: # Enable workflow to be run manually

# Disable all access to the GitHub API by default
# This default can be overridden for individual workflows and jobs
# Documentation: https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#permissions
permissions: {}

# Cancel the currently running CI job if you push a change while CI is running
# Documentation: https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04 # Needed for Python 3.7
name: Run tests
env:
PYTHON_VERSION: 3.7.17
defaults:
run:
shell: bash -leo pipefail {0}
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Set Up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: "3.7"
python-version: ${{ env.PYTHON_VERSION }}
- name: Install daidepp
run: |
pip install -U pip
pip install -e .[dev]
- name: Test
run: |
Expand Down
23 changes: 12 additions & 11 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,24 @@ python_requires = >=3.7
install_requires =
parsimonious==0.9.0
importlib-metadata>=1.4.0 ; python_version < "3.8"
typing_extensions>=3.10.0.0 ; python_version < "3.8"

[options.packages.find]
where = src

[options.extras_require]
dev =
black>=22.8.0
docformatter==1.4
isort>=5.10.1
pydocstyle==6.1.1
pylint==2.12.2
pytest==7.0.0
pytest-black==0.3.12
pytest-cov==3.0.0
pytest-dependency==0.5.1
pytest-mypy==0.9.1
pytest-timeout==2.1.0
black==23.3.0
docformatter==1.7.5
isort==5.11.5
pydocstyle==6.3.0
pylint==2.17.7
pytest==7.4.4
pytest-black==0.6.0
pytest-cov==4.1.0
pytest-dependency==0.6.0
pytest-mypy==0.10.3
pytest-timeout==2.3.1

[isort]
multi_line_output = 3
Expand Down
5 changes: 4 additions & 1 deletion src/daidepp/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from typing_extensions import Literal
try:
from typing import Literal
except ImportError:
from typing_extensions import Literal

Power = Literal["AUS", "ENG", "FRA", "GER", "ITA", "RUS", "TUR"]
UnitType = Literal["AMY", "FLT"]
Expand Down
6 changes: 4 additions & 2 deletions src/daidepp/grammar/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
from __future__ import annotations

from typing import Dict, Tuple
from typing_extensions import get_args

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

DAIDELevel = Literal[
0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160
Expand Down
6 changes: 5 additions & 1 deletion src/daidepp/grammar/grammar_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
from typing import Dict, List, Optional, Set, Tuple, Union

from parsimonious.grammar import Grammar
from typing_extensions import Literal

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

from daidepp.constants import PressKeywords
from daidepp.grammar.grammar import (
Expand Down
5 changes: 4 additions & 1 deletion src/daidepp/keywords/base_keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
from dataclasses import dataclass
from typing import Optional, Tuple, Union

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

from daidepp.constants import *
from daidepp.keywords.daide_object import _DAIDEObject
Expand Down
6 changes: 5 additions & 1 deletion src/daidepp/visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
from typing import Any

from parsimonious.nodes import Node, NodeVisitor
from typing_extensions import get_args

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

from daidepp.constants import ProvinceNoCoast
from daidepp.keywords.base_keywords import *
Expand Down
6 changes: 5 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import pytest
from typing_extensions import get_args

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

from daidepp.grammar import create_daide_grammar
from daidepp.grammar.grammar import DAIDELevel, MAX_DAIDE_LEVEL
Expand Down