Skip to content

Commit 8a14426

Browse files
committed
Update for python-3.12
Also, drop testing for some older versions and adopt testing against newer taskwarrior.
1 parent 3256c92 commit 8a14426

File tree

7 files changed

+30
-35
lines changed

7 files changed

+30
-35
lines changed

.github/workflows/test.yml

+3-9
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,8 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
python-version: [3.5, 3.6, 3.7, 3.8]
13-
taskwarrior-version: [2.5.0, 2.5.1, 2.5.3]
14-
exclude:
15-
# Taskwarriror 3.5.3 only supported on Python 3.7+.
16-
- python-version: 3.5
17-
taskwarrior-version: 2.5.3
18-
- python-version: 3.6
19-
taskwarrior-version: 2.5.3
12+
python-version: [3.9, "3.10", 3.11, 3.12]
13+
taskwarrior-version: [2.5.3, 2.6.2]
2014
steps:
2115
- uses: actions/checkout@v2
2216
- name: Set up Python ${{matrix.python-version}}
@@ -25,7 +19,7 @@ jobs:
2519
python-version: ${{matrix.python-version}}
2620
- name: Install Taskwarrior ${{matrix.taskwarrior-version}}
2721
run: |
28-
sudo apt-get install -y python-dev cmake build-essential libgnutls28-dev uuid-dev gnutls-bin chrpath libssl-dev libfontconfig1-dev
22+
sudo apt-get install -y python3-dev cmake build-essential libgnutls28-dev uuid-dev gnutls-bin chrpath libssl-dev libfontconfig1-dev
2923
git clone https://github.com/GothenburgBitFactory/taskwarrior.git
3024
cd taskwarrior
3125
git checkout v${{matrix.taskwarrior-version}}

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
python-dateutil
22
pytz
33
kitchen
4+
packaging

setup.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,16 @@
3838
REQUIREMENTS[category] = requirements
3939

4040
setup(name='taskw',
41-
version='2.0.0',
41+
version='2.1.0',
4242
description="Python bindings for your taskwarrior database",
4343
long_description=long_description,
4444
classifiers=[
4545
"Development Status :: 5 - Production/Stable",
4646
"Programming Language :: Python :: 3",
47-
"Programming Language :: Python :: 3.4",
48-
"Programming Language :: Python :: 3.5",
49-
"Programming Language :: Python :: 3.6",
50-
"Programming Language :: Python :: 3.7",
51-
"Programming Language :: Python :: 3.8",
47+
"Programming Language :: Python :: 3.9",
48+
"Programming Language :: Python :: 3.10",
49+
"Programming Language :: Python :: 3.11",
50+
"Programming Language :: Python :: 3.12",
5251
"License :: OSI Approved :: GNU General Public License (GPL)",
5352
"Intended Audience :: Developers",
5453
],

taskw/fields/commaseparateduuid.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from distutils.version import LooseVersion
1+
from packaging.version import Version
22

33
import uuid
44

55
from .base import DirtyableList, Field
66

77

88
class CommaSeparatedUUIDField(Field):
9-
version = LooseVersion('2.4')
9+
version = Version('2.4')
1010

1111
def deserialize(self, value):
1212
if not value:
@@ -27,7 +27,7 @@ def serialize(self, value):
2727
if not hasattr(value, '__iter__'):
2828
raise ValueError("Value must be list or tuple, not %r." % value)
2929

30-
if self.version < LooseVersion('2.5'):
30+
if self.version < Version('2.5'):
3131
return ','.join([str(v) for v in value])
3232
else:
3333
# We never hit this second code branch now. taskwarrior changed

taskw/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import dateutil.tz
99
import pytz
1010

11-
from distutils.version import LooseVersion
11+
from packaging.version import Version
1212

1313

1414
DATE_FORMAT = '%Y%m%dT%H%M%SZ'
@@ -91,7 +91,7 @@ def encode_query(value, version, query=True):
9191
])
9292
)
9393
else:
94-
if k.endswith(".is") and version >= LooseVersion('2.4'):
94+
if k.endswith(".is") and version >= Version('2.4'):
9595
args.append(
9696
'%s == "%s"' % (
9797
k[:-3],

taskw/warrior.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"""
1212
import abc
1313
import copy
14-
from distutils.version import LooseVersion
14+
from packaging.version import Version
1515
import logging
1616
import os
1717
import re
@@ -432,13 +432,13 @@ def __init__(
432432
self._marshal = marshal
433433
self.config = TaskRc(config_filename, overrides=config_overrides)
434434

435-
if self.get_version() >= LooseVersion('2.4'):
435+
if self.get_version() >= Version('2.4'):
436436
self.DEFAULT_CONFIG_OVERRIDES['verbose'] = 'new-uuid'
437437
# Combination of
438438
# https://github.com/GothenburgBitFactory/taskwarrior/issues/1953
439439
# and dictionaries random order may cause task add failures in
440440
# Python versions before 3.7
441-
if (self.get_version() >= LooseVersion('2.5.3') and
441+
if (self.get_version() >= Version('2.5.3') and
442442
sys.hexversion < 0x03070000):
443443
warnings.once(
444444
"Python < 3.7 with TaskWarrior => 2.5.3 is not suppoprted. "
@@ -553,7 +553,7 @@ def can_use(cls):
553553
""" Returns true if runtime requirements of experimental mode are met
554554
"""
555555
try:
556-
return cls.get_version() > LooseVersion('2')
556+
return cls.get_version() > Version('2')
557557
except FileNotFoundError:
558558
# FileNotFound is raised if subprocess.Popen fails to find
559559
# the executable.
@@ -570,10 +570,10 @@ def get_version(cls):
570570
raise FileNotFoundError(
571571
"Unable to find the 'task' command-line tool."
572572
)
573-
return LooseVersion(taskwarrior_version.decode())
573+
return Version(taskwarrior_version.decode())
574574

575575
def sync(self, init=False):
576-
if self.get_version() < LooseVersion('2.3'):
576+
if self.get_version() < Version('2.3'):
577577
raise UnsupportedVersionException(
578578
"'sync' requires version 2.3 of taskwarrior or later."
579579
)
@@ -682,7 +682,7 @@ def task_add(self, description, tags=None, **kw):
682682

683683
# With older versions of taskwarrior, you can specify whatever uuid you
684684
# want when adding a task.
685-
if self.get_version() < LooseVersion('2.4'):
685+
if self.get_version() < Version('2.4'):
686686
task['uuid'] = str(uuid.uuid4())
687687
elif 'uuid' in task:
688688
del task['uuid']
@@ -697,7 +697,7 @@ def task_add(self, description, tags=None, **kw):
697697
# However, in 2.4 and later, you cannot specify whatever uuid you want
698698
# when adding a task. Instead, you have to specify rc.verbose=new-uuid
699699
# and then parse the assigned uuid out from stdout.
700-
if self.get_version() >= LooseVersion('2.4'):
700+
if self.get_version() >= Version('2.4'):
701701
task['uuid'] = re.search(UUID_REGEX, stdout).group(0)
702702

703703
id, added_task = self.get_task(uuid=task['uuid'])

tox.ini

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
[tox]
2-
envlist = py{35,36,37,38}-tw{250,251} py{38}-tw{253}
2+
envlist = py{39,310,311,312}-tw{253,262}
33
downloadcache = {toxworkdir}/_download/
44

55
[testenv]
66
basepython =
7-
py35: python3.5
8-
py36: python3.6
9-
py37: python3.7
10-
py38: python3.8
7+
py39: python3.9
8+
py310: python3.10
9+
py311: python3.11
10+
py312: python3.12
11+
allowlist_externals =
12+
{toxinidir}/.tox_build_taskwarrior.sh
1113
deps =
1214
-r{toxinidir}/requirements.txt
1315
-r{toxinidir}/test_requirements.txt
1416
setenv =
15-
tw250: TASKWARRIOR=v2.5.0
16-
tw251: TASKWARRIOR=v2.5.1
1717
tw253: TASKWARRIOR=v2.5.3
18+
tw262: TASKWARRIOR=v2.6.2
1819
sitepackages = False
1920
commands =
2021
{toxinidir}/.tox_build_taskwarrior.sh "{envdir}" "{toxinidir}"

0 commit comments

Comments
 (0)