Skip to content

Commit 2ace19f

Browse files
committed
modernise packaging
update actions move to pytest move tests out of src
1 parent 8856fdf commit 2ace19f

31 files changed

+873
-1119
lines changed

.coveragerc

-3
This file was deleted.

.github/workflows/lint.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ on: [push, pull_request, workflow_dispatch]
44

55
jobs:
66
lint:
7-
runs-on: ubuntu-20.04
7+
runs-on: ubuntu-24.04
88

99
steps:
10-
- uses: actions/checkout@v2
11-
- uses: actions/setup-python@v2
12-
- uses: pre-commit/action@v2.0.3
10+
- uses: actions/checkout@v4
11+
- uses: actions/setup-python@v5
12+
with:
13+
python-version: "3.12"
14+
- uses: pre-commit/action@v3.0.1

.github/workflows/test.yml

+5-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
python-version: ["pypy-3.8", "3.7", "3.8", "3.9", "3.10"]
14+
python-version: ["pypy-3.9", "3.9", "3.10", "3.11", "3.12"]
1515
os: [ubuntu-latest, macos-latest, windows-latest]
1616
include:
1717
# Include new variables for Codecov
@@ -20,27 +20,24 @@ jobs:
2020
- { codecov-flag: GHA_Windows, os: windows-latest }
2121

2222
steps:
23-
- uses: actions/checkout@v2
23+
- uses: actions/checkout@v4
2424

2525
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v2
26+
uses: actions/setup-python@v5
2727
with:
2828
python-version: ${{ matrix.python-version }}
2929
cache: pip
30-
cache-dependency-path: "setup.py"
3130

3231
- name: Install dependencies
3332
run: |
34-
python -m pip install -U pip
35-
python -m pip install -U wheel
36-
python -m pip install -U tox
33+
python -m pip install -U pip wheel tox
3734
3835
- name: Tox tests
3936
run: |
4037
tox -e py
4138
4239
- name: Upload coverage
43-
uses: codecov/codecov-action@v2
40+
uses: codecov/codecov-action@v4
4441
with:
4542
flags: ${{ matrix.codecov-flag }}
4643
name: ${{ matrix.os }} Python ${{ matrix.python-version }}

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ parts
1212
.coverage
1313
coverage.xml
1414
htmlcov
15+
src/isodate/version.py
16+
.eggs
17+
.vscode/

.pre-commit-config.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
repos:
22
- repo: https://github.com/asottile/pyupgrade
3-
rev: v2.29.1
3+
rev: v3.17.0
44
hooks:
55
- id: pyupgrade
6-
args: [--py37-plus]
6+
args: [--py39-plus]
77

88
- repo: https://github.com/pycqa/flake8
9-
rev: 4.0.1
9+
rev: 7.1.1
1010
hooks:
1111
- id: flake8
1212
args:
1313
- "--max-line-length=88"
1414

1515
- repo: https://github.com/pre-commit/pygrep-hooks
16-
rev: v1.9.0
16+
rev: v1.10.0
1717
hooks:
1818
- id: python-check-blanket-noqa
1919

2020
- repo: https://github.com/pre-commit/pre-commit-hooks
21-
rev: v4.0.1
21+
rev: v5.0.0
2222
hooks:
2323
- id: check-merge-conflict
2424
- id: check-yaml

CHANGES.txt

+13-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,23 @@
22
CHANGES
33
=======
44

5-
0.7.0 (unreleased)
5+
0.7.1 (unreleased)
6+
------------------
7+
8+
- no changes yet
9+
10+
11+
0.7.0 (2024-10-08)
612
------------------
713

814
- drop end of life python versions
915
- Don't match garbage characters at the end of parsed strings #16 (Gabriel de Perthuis)
10-
- Breaking: fractional seconds are cut off to microseconds (round down)
16+
17+
18+
Potentially breaking changes:
19+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20+
21+
- Fractional seconds are cut off to microseconds (always round down)
1122
- Allow control over return type of parse_duration #64 (Felix Claessen)
1223

1324

MANIFEST.in

-2
This file was deleted.

README.rst

+3-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ As this module maps ISO 8601 dates/times to standard Python data types, like
3333
all possible ISO 8601 dates/times. For instance, dates before 0001-01-01 are
3434
not allowed by the Python *date* and *datetime* classes. Additionally
3535
fractional seconds are limited to microseconds. That means if the parser finds
36-
for instance nanoseconds it will round it to microseconds.
36+
for instance nanoseconds it will round it down to microseconds.
3737

3838
Documentation
3939
-------------
@@ -88,8 +88,7 @@ Installation
8888

8989
This module can easily be installed with Python standard installation methods.
9090

91-
Either use *python setup.py install* or in case you have *setuptools* or
92-
*distribute* available, you can also use *easy_install*.
91+
Use *pip install isodate*.
9392

9493
Limitations
9594
-----------
@@ -113,4 +112,4 @@ the methods and their limitations.
113112
The source release provides a *setup.py* script,
114113
which can be used to run the unit tests included.
115114

116-
Source code is available at `<http://github.com/gweis/isodate>`_.
115+
Source code is available at `<https://github.com/gweis/isodate>`_.

pyproject.toml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
[project]
2+
name = "isodate"
3+
description = "An ISO 8601 date/time/duration parser and formatter"
4+
# TODO: long_description = "file: README.rst, CHANGES.txt, TODO.txt"
5+
# TODO: url = "https://github.com/gweis/isodate/"
6+
authors = [{name="Gerhard Weis"}]
7+
# keywords =
8+
license = {file = "LICENSE"}
9+
# license = {text="BSD-3-Clause"}
10+
#TODO: license_files = "LICENSE"
11+
classifiers = [
12+
"Development Status :: 4 - Beta",
13+
"Intended Audience :: Developers",
14+
"License :: OSI Approved :: BSD License",
15+
"Operating System :: OS Independent",
16+
"Programming Language :: Python",
17+
"Programming Language :: Python :: 3",
18+
"Programming Language :: Python :: 3.9",
19+
"Programming Language :: Python :: 3.10",
20+
"Programming Language :: Python :: 3.11",
21+
"Programming Language :: Python :: 3.12",
22+
"Programming Language :: Python :: 3.13",
23+
"Programming Language :: Python :: Implementation :: CPython",
24+
"Programming Language :: Python :: Implementation :: PyPy",
25+
"Topic :: Internet",
26+
"Topic :: Software Development :: Libraries :: Python Modules",
27+
]
28+
# requires-python = ">3.7"
29+
dynamic = ["version"]
30+
31+
32+
[build-system]
33+
requires = ["setuptools", "setuptools_scm[toml]"]
34+
build-backend = "setuptools.build_meta"
35+
36+
[tool.setuptools_scm]
37+
write_to = "src/isodate/version.py"
38+
fallback_version = "0.0.0.dev0"
39+
40+
41+
[tool.pytest.ini_options]
42+
testpaths = ["tests"]
43+
filterwarnings = [
44+
# treat all warnings as errors
45+
"error",
46+
# ignore:<regexp>
47+
# e.g.:
48+
# ignore:jsonschema.RefResolver is deprecated as of v4.18.0
49+
]
50+
junit_family = "xunit2"
51+
52+
[tool.coverage.run]
53+
source_pkgs = ["isodate"]
54+
omit = ["tests/"]
55+
56+
[tool.black]
57+
line-length = 88
58+
59+
[tool.isort]
60+
profile = "black"

setup.py

-43
This file was deleted.

src/isodate/__init__.py

+44-22
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,51 @@
44
55
This module contains also various pre-defined ISO 8601 format strings.
66
"""
7-
from isodate.isodates import parse_date, date_isoformat
8-
from isodate.isotime import parse_time, time_isoformat
9-
from isodate.isodatetime import parse_datetime, datetime_isoformat
10-
from isodate.isoduration import parse_duration, duration_isoformat
7+
8+
from isodate.duration import Duration
9+
from isodate.isodates import date_isoformat, parse_date
10+
from isodate.isodatetime import datetime_isoformat, parse_datetime
11+
from isodate.isoduration import duration_isoformat, parse_duration
1112
from isodate.isoerror import ISO8601Error
13+
from isodate.isostrf import (
14+
D_ALT_BAS,
15+
D_ALT_BAS_ORD,
16+
D_ALT_EXT,
17+
D_ALT_EXT_ORD,
18+
D_DEFAULT,
19+
D_WEEK,
20+
DATE_BAS_COMPLETE,
21+
DATE_BAS_MONTH,
22+
DATE_BAS_ORD_COMPLETE,
23+
DATE_BAS_WEEK,
24+
DATE_BAS_WEEK_COMPLETE,
25+
DATE_CENTURY,
26+
DATE_EXT_COMPLETE,
27+
DATE_EXT_MONTH,
28+
DATE_EXT_ORD_COMPLETE,
29+
DATE_EXT_WEEK,
30+
DATE_EXT_WEEK_COMPLETE,
31+
DATE_YEAR,
32+
DT_BAS_COMPLETE,
33+
DT_BAS_ORD_COMPLETE,
34+
DT_BAS_WEEK_COMPLETE,
35+
DT_EXT_COMPLETE,
36+
DT_EXT_ORD_COMPLETE,
37+
DT_EXT_WEEK_COMPLETE,
38+
TIME_BAS_COMPLETE,
39+
TIME_BAS_MINUTE,
40+
TIME_EXT_COMPLETE,
41+
TIME_EXT_MINUTE,
42+
TIME_HOUR,
43+
TZ_BAS,
44+
TZ_EXT,
45+
TZ_HOUR,
46+
strftime,
47+
)
48+
from isodate.isotime import parse_time, time_isoformat
1249
from isodate.isotzinfo import parse_tzinfo, tz_isoformat
13-
from isodate.tzinfo import UTC, FixedOffset, LOCAL
14-
from isodate.duration import Duration
15-
from isodate.isostrf import strftime
16-
from isodate.isostrf import DATE_BAS_COMPLETE, DATE_BAS_ORD_COMPLETE
17-
from isodate.isostrf import DATE_BAS_WEEK, DATE_BAS_WEEK_COMPLETE
18-
from isodate.isostrf import DATE_CENTURY, DATE_EXT_COMPLETE
19-
from isodate.isostrf import DATE_EXT_ORD_COMPLETE, DATE_EXT_WEEK
20-
from isodate.isostrf import DATE_EXT_WEEK_COMPLETE, DATE_YEAR
21-
from isodate.isostrf import DATE_BAS_MONTH, DATE_EXT_MONTH
22-
from isodate.isostrf import TIME_BAS_COMPLETE, TIME_BAS_MINUTE
23-
from isodate.isostrf import TIME_EXT_COMPLETE, TIME_EXT_MINUTE
24-
from isodate.isostrf import TIME_HOUR
25-
from isodate.isostrf import TZ_BAS, TZ_EXT, TZ_HOUR
26-
from isodate.isostrf import DT_BAS_COMPLETE, DT_EXT_COMPLETE
27-
from isodate.isostrf import DT_BAS_ORD_COMPLETE, DT_EXT_ORD_COMPLETE
28-
from isodate.isostrf import DT_BAS_WEEK_COMPLETE, DT_EXT_WEEK_COMPLETE
29-
from isodate.isostrf import D_DEFAULT, D_WEEK, D_ALT_EXT, D_ALT_BAS
30-
from isodate.isostrf import D_ALT_BAS_ORD, D_ALT_EXT_ORD
50+
from isodate.tzinfo import LOCAL, UTC, FixedOffset
51+
from isodate.version import version as __version__
3152

3253
__all__ = [
3354
"parse_date",
@@ -78,4 +99,5 @@
7899
"D_ALT_BAS",
79100
"D_ALT_BAS_ORD",
80101
"D_ALT_EXT_ORD",
102+
"__version__",
81103
]

src/isodate/duration.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
The class Duration allows to define durations in years and months and can be
55
used as limited replacement for timedelta objects.
66
"""
7+
78
from datetime import timedelta
8-
from decimal import Decimal, ROUND_FLOOR
9+
from decimal import ROUND_FLOOR, Decimal
910

1011

1112
def fquotmod(val, low, high):

src/isodate/isodates.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
standard. The only limitations it has, are given by the Python datetime.date
77
implementation, which does not support dates before 0001-01-01.
88
"""
9+
910
import re
1011
from datetime import date, timedelta
1112

12-
from isodate.isostrf import strftime, DATE_EXT_COMPLETE
1313
from isodate.isoerror import ISO8601Error
14+
from isodate.isostrf import DATE_EXT_COMPLETE, strftime
1415

1516
DATE_REGEX_CACHE = {}
1617
# A dictionary to cache pre-compiled regular expressions.

src/isodate/isodatetime.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
For this job it uses the parse_date and parse_time methods defined in date
55
and time module.
66
"""
7+
78
from datetime import datetime
89

9-
from isodate.isostrf import strftime
10-
from isodate.isostrf import DATE_EXT_COMPLETE, TIME_EXT_COMPLETE, TZ_EXT
1110
from isodate.isodates import parse_date
1211
from isodate.isoerror import ISO8601Error
12+
from isodate.isostrf import DATE_EXT_COMPLETE, TIME_EXT_COMPLETE, TZ_EXT, strftime
1313
from isodate.isotime import parse_time
1414

1515

src/isodate/isoduration.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
It also provides a wrapper to strftime. This wrapper makes it easier to
55
format timedelta or Duration instances as ISO conforming strings.
66
"""
7+
8+
import re
79
from datetime import timedelta
810
from decimal import Decimal
9-
import re
1011

1112
from isodate.duration import Duration
12-
from isodate.isoerror import ISO8601Error
1313
from isodate.isodatetime import parse_datetime
14-
from isodate.isostrf import strftime, D_DEFAULT
14+
from isodate.isoerror import ISO8601Error
15+
from isodate.isostrf import D_DEFAULT, strftime
1516

1617
ISO8601_PERIOD_REGEX = re.compile(
1718
r"^(?P<sign>[+-])?"

0 commit comments

Comments
 (0)