Skip to content

Commit effda06

Browse files
authored
feat(python): Add python 3.11 support and cleanup (#69)
This PR removes python 3.6, as it's not maintained any more. Additionally, it adds support for python 3.10 and 3.11 and updated pre-commits and dependencies to fit the new python versions.
1 parent c764db8 commit effda06

File tree

14 files changed

+596
-518
lines changed

14 files changed

+596
-518
lines changed

.github/workflows/ci-production.yml

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,48 +10,37 @@ on:
1010
- created
1111

1212
jobs:
13-
linux-tests:
13+
pytest:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
config:
18-
- python-version: 3.6
19-
tox: 36
20-
- python-version: 3.7
21-
tox: 37
22-
- python-version: 3.8
23-
tox: 38
24-
- python-version: 3.9
25-
tox: 39
26-
- python-version: pypy-3.6
27-
tox: py3
28-
- python-version: pypy-3.7
29-
tox: py3
30-
poetry-version: [ 1.1.4 ]
31-
os: [ macos-latest, windows-2019, ubuntu-20.04, ubuntu-18.04 ]
17+
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11", "pypy3.7", "pypy3.8", "pypy3.9" ]
18+
poetry-version: [ "latest" ]
19+
os: [ ubuntu-20.04, macos-latest, windows-latest ]
3220
runs-on: ${{ matrix.os }}
21+
name: Python ${{ matrix.python-version }} / Poetry ${{ matrix.poetry-version }} / ${{ matrix.os }}
22+
defaults:
23+
run:
24+
shell: bash
3325
steps:
34-
- uses: actions/checkout@v2
35-
- name: Set up testing Python ${{ matrix.config.python-version }}
36-
uses: actions/setup-python@v2
26+
- uses: actions/checkout@v3
3727
with:
38-
python-version: ${{ matrix.config.python-version }}
39-
architecture: x64
40-
- name: Set up base Python 3.9
41-
uses: actions/setup-python@v2
28+
fetch-depth: 0
29+
- name: Set up Python ${{ matrix.python-version }}
30+
uses: actions/setup-python@v4
4231
with:
43-
python-version: 3.9
44-
architecture: x64
45-
- name: Python Poetry Action
46-
uses: abatilo/actions-poetry@v2.1.0
32+
python-version: ${{ matrix.python-version }}
33+
cache: 'pip'
34+
- name: Run Poetry action
35+
uses: abatilo/actions-poetry@v2
4736
with:
4837
poetry-version: ${{ matrix.poetry-version }}
38+
- name: View poetry --version
39+
run: poetry --version
4940
- name: Install dependencies
50-
run: |
51-
python -m pip install --upgrade pip
52-
pip install tox
53-
- name: Run Tox
54-
run: tox -e py${{ matrix.config.tox }}
41+
run: poetry install
42+
- name: Run tests
43+
run: poetry run pytest
5544
- name: Upload coverage to Codecov
5645
uses: codecov/codecov-action@v1
5746
with:
@@ -65,17 +54,17 @@ jobs:
6554
name: Build and publish Python distributions 📦 to PyPI and TestPyPI
6655
runs-on: ubuntu-20.04
6756
needs:
68-
- linux-tests
57+
- pytest
6958
steps:
7059
- uses: actions/checkout@v2
7160
- name: Set up base Python 3.9
7261
uses: actions/setup-python@v2
7362
with:
7463
python-version: 3.9
7564
- name: Python Poetry Action
76-
uses: abatilo/actions-poetry@v2.1.0
65+
uses: abatilo/actions-poetry@v2
7766
with:
78-
poetry-version: 1.1.4
67+
poetry-version: latest
7968
- name: Publish distribution 📦 with test.pypi.org
8069
if: startsWith(github.ref, 'refs/tags')
8170
run: |

.github/workflows/ci-tests.yml

Lines changed: 37 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -14,67 +14,52 @@ jobs:
1414
uses: actions/setup-python@v2
1515
with:
1616
python-version: 3.9
17-
- name: Python Poetry Action
18-
uses: abatilo/[email protected]
19-
with:
20-
poetry-version: 1.1.4
21-
- name: Install lint dependencies
17+
- name: Update pip
2218
run: |
23-
pip install tox pytest pytest-cov
19+
python -m pip install --upgrade pip
2420
- name: Install and run pre-commit
2521
uses: pre-commit/[email protected]
2622
with:
2723
extra_args: --all-files
28-
test:
24+
pytest:
2925
needs:
3026
- lint
3127
strategy:
3228
fail-fast: false
3329
matrix:
34-
config:
35-
- python-version: 3.6
36-
tox: 36
37-
- python-version: 3.7
38-
tox: 37
39-
- python-version: 3.8
40-
tox: 38
41-
- python-version: 3.9
42-
tox: 39
43-
- python-version: pypy-3.6
44-
tox: py3
45-
- python-version: pypy-3.7
46-
tox: py3
47-
poetry-version: [ 1.1.4 ]
48-
os: [ macos-latest, windows-2019, ubuntu-20.04, ubuntu-18.04 ]
30+
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11", "pypy3.7", "pypy3.8", "pypy3.9" ]
31+
poetry-version: [ "latest" ]
32+
os: [ ubuntu-20.04, macos-latest, windows-latest ]
4933
runs-on: ${{ matrix.os }}
34+
name: Python ${{ matrix.python-version }} / Poetry ${{ matrix.poetry-version }} / ${{ matrix.os }}
35+
defaults:
36+
run:
37+
shell: bash
5038
steps:
51-
- uses: actions/checkout@v2
52-
- name: Set up testing Python ${{ matrix.config.python-version }}
53-
uses: actions/setup-python@v2
54-
with:
55-
python-version: ${{ matrix.config.python-version }}
56-
architecture: x64
57-
- name: Set up base Python 3.9
58-
uses: actions/setup-python@v2
59-
with:
60-
python-version: 3.9
61-
architecture: x64
62-
- name: Python Poetry Action
63-
uses: abatilo/[email protected]
64-
with:
65-
poetry-version: ${{ matrix.poetry-version }}
66-
- name: Install dependencies
67-
run: |
68-
python -m pip install --upgrade pip
69-
pip install tox
70-
- name: Run Tox
71-
run: tox -e py${{ matrix.config.tox }}
72-
- name: Upload coverage to Codecov
73-
uses: codecov/codecov-action@v1
74-
with:
75-
token: ${{ secrets.CODECOV_TOKEN }}
76-
flags: unittests
77-
env_vars: OS,PYTHON
78-
name: codecov-umbrella
79-
fail_ci_if_error: true
80-
verbose: true
39+
- uses: actions/checkout@v3
40+
with:
41+
fetch-depth: 0
42+
- name: Set up Python ${{ matrix.python-version }}
43+
uses: actions/setup-python@v4
44+
with:
45+
python-version: ${{ matrix.python-version }}
46+
cache: 'pip'
47+
- name: Run Poetry action
48+
uses: abatilo/actions-poetry@v2
49+
with:
50+
poetry-version: ${{ matrix.poetry-version }}
51+
- name: View poetry --version
52+
run: poetry --version
53+
- name: Install dependencies
54+
run: poetry install
55+
- name: Run tests
56+
run: poetry run pytest
57+
- name: Upload coverage to Codecov
58+
uses: codecov/codecov-action@v1
59+
with:
60+
token: ${{ secrets.CODECOV_TOKEN }}
61+
flags: unittests
62+
env_vars: OS,PYTHON
63+
name: codecov-umbrella
64+
fail_ci_if_error: true
65+
verbose: true

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.tox/
2-
.venv/
2+
.venv*
3+
.env*
34
.coverage
45
**/.ipynb_checkpoints/
56
*.geojson

.pre-commit-config.yaml

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v3.2.0
3+
rev: v4.4.0
44
hooks:
55
- id: trailing-whitespace
66
- id: end-of-file-fixer
@@ -22,16 +22,27 @@ repos:
2222
args: [ --branch, main ]
2323

2424
- repo: https://github.com/ambv/black
25-
rev: stable
25+
rev: 23.3.0
2626
hooks:
2727
- id: black
2828
args: # arguments to configure black
2929
- --line-length=80
30-
language_version: python3.9
31-
- repo: https://gitlab.com/pycqa/flake8
32-
rev: "3.8.4"
30+
- repo: https://github.com/PyCQA/flake8
31+
rev: 6.0.0
3332
hooks:
3433
- id: flake8
34+
additional_dependencies:
35+
[
36+
"flake8-bugbear",
37+
"flake8-coding",
38+
"flake8-comprehensions",
39+
"flake8-debugger",
40+
"flake8-deprecated",
41+
"flake8-pep3101",
42+
"flake8-polyfill",
43+
"flake8-print",
44+
"flake8-docstrings",
45+
]
3546
exclude: |
3647
(?x)(
3748
^test/* |
@@ -40,16 +51,3 @@ repos:
4051
args:
4152
- "--max-line-length=120"
4253
- "--ignore=P101,D202,D401"
43-
additional_dependencies:
44-
[
45-
"flake8-bugbear==19.8.0",
46-
"flake8-coding==1.3.2",
47-
"flake8-comprehensions==3.0.1",
48-
"flake8-debugger==3.2.1",
49-
"flake8-deprecated==1.3",
50-
"flake8-pep3101==1.2.1",
51-
"flake8-polyfill==1.0.2",
52-
"flake8-print==3.1.4",
53-
"flake8-string-format==0.2.3",
54-
"flake8-docstrings==1.5.0",
55-
]

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ Google Inc.
1616

1717
# Modified to fit ORS needs by
1818

19+
Julian Psotta <[email protected]>
1920
Nils Nolde <[email protected]>

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
# Please keep the list sorted by first name.
88

9+
Julian Psotta <[email protected]>
910
Nils Nolde <[email protected]>
1011

1112
# The following people contributed to the original Python Client for Google Maps Services:

docs/source/conf.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,18 @@
4646
master_doc = "index"
4747

4848
# General information about the project.
49-
project = u"openrouteservice-py"
50-
copyright = u"2018, Nils Nolde"
51-
author = u"Nils Nolde"
49+
project = "openrouteservice-py"
50+
copyright = "2023, HeiGIT gGmbH"
51+
author = "HeiGIT gGmbH"
5252

5353
# The version info for the project you're documenting, acts as replacement for
5454
# |version| and |release|, also used in various other places throughout the
5555
# built documents.
5656
#
5757
# The short X.Y version.
58-
version = u"0.4"
58+
version = "0.4"
5959
# The full version, including alpha/beta/rc tags.
60-
release = u"0.4"
60+
release = "0.4"
6161

6262
# The language for content autogenerated by Sphinx. Refer to documentation
6363
# for a list of supported languages.
@@ -139,8 +139,8 @@
139139
(
140140
master_doc,
141141
"openrouteservice-py.tex",
142-
u"openrouteservice-py Documentation",
143-
u"Nils Nolde",
142+
"openrouteservice-py Documentation",
143+
"HeiGIT gGmbH",
144144
"manual",
145145
),
146146
]
@@ -153,7 +153,7 @@
153153
(
154154
master_doc,
155155
"openrouteservice-py",
156-
u"openrouteservice-py Documentation",
156+
"openrouteservice-py Documentation",
157157
[author],
158158
1,
159159
)
@@ -168,7 +168,7 @@
168168
(
169169
master_doc,
170170
"openrouteservice-py",
171-
u"openrouteservice-py Documentation",
171+
"openrouteservice-py Documentation",
172172
author,
173173
"openrouteservice-py",
174174
"One line description of project.",

openrouteservice/client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,6 @@ def _normalize_for_urlencode(value): # pragma: no cover
385385

386386
return _normalize_for_urlencode(str(value))
387387

388-
389388
except NameError:
390389

391390
def _normalize_for_urlencode(value):

openrouteservice/convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,6 @@ def decode_polyline(polyline, is3d=False):
196196
else:
197197
points.append([round(lng * 1e-5, 6), round(lat * 1e-5, 6)])
198198

199-
geojson = {u"type": u"LineString", u"coordinates": points}
199+
geojson = {"type": "LineString", "coordinates": points}
200200

201201
return geojson

openrouteservice/directions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,15 @@ def directions(
200200
# call optimization endpoint and get new order of waypoints
201201
if optimize_waypoints is not None and not dry_run:
202202
if len(coordinates) <= 3:
203-
warnings.warn(
203+
warnings.warn( # noqa: B028
204204
"Less than 4 coordinates, nothing to optimize!", UserWarning
205205
)
206206
elif options:
207-
warnings.warn(
207+
warnings.warn( # noqa: B028
208208
"Options are not compatible with optimization.", UserWarning
209209
)
210210
elif preference == "shortest":
211-
warnings.warn(
211+
warnings.warn( # noqa: B028
212212
"Shortest is not compatible with optimization.", UserWarning
213213
)
214214
else:

0 commit comments

Comments
 (0)