Skip to content

Commit

Permalink
modernise packaging
Browse files Browse the repository at this point in the history
update actions
move to pytest
move tests out of src
  • Loading branch information
gweis committed Oct 8, 2024
1 parent 8856fdf commit 2ace19f
Show file tree
Hide file tree
Showing 31 changed files with 873 additions and 1,119 deletions.
3 changes: 0 additions & 3 deletions .coveragerc

This file was deleted.

10 changes: 6 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ on: [push, pull_request, workflow_dispatch]

jobs:
lint:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/[email protected]
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: pre-commit/[email protected]
13 changes: 5 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["pypy-3.8", "3.7", "3.8", "3.9", "3.10"]
python-version: ["pypy-3.9", "3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-latest, macos-latest, windows-latest]
include:
# Include new variables for Codecov
Expand All @@ -20,27 +20,24 @@ jobs:
- { codecov-flag: GHA_Windows, os: windows-latest }

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: "setup.py"

- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U wheel
python -m pip install -U tox
python -m pip install -U pip wheel tox
- name: Tox tests
run: |
tox -e py
- name: Upload coverage
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v4
with:
flags: ${{ matrix.codecov-flag }}
name: ${{ matrix.os }} Python ${{ matrix.python-version }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ parts
.coverage
coverage.xml
htmlcov
src/isodate/version.py
.eggs
.vscode/
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.29.1
rev: v3.17.0
hooks:
- id: pyupgrade
args: [--py37-plus]
args: [--py39-plus]

- repo: https://github.com/pycqa/flake8
rev: 4.0.1
rev: 7.1.1
hooks:
- id: flake8
args:
- "--max-line-length=88"

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v5.0.0
hooks:
- id: check-merge-conflict
- id: check-yaml
Expand Down
15 changes: 13 additions & 2 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@
CHANGES
=======

0.7.0 (unreleased)
0.7.1 (unreleased)
------------------

- no changes yet


0.7.0 (2024-10-08)
------------------

- drop end of life python versions
- Don't match garbage characters at the end of parsed strings #16 (Gabriel de Perthuis)
- Breaking: fractional seconds are cut off to microseconds (round down)


Potentially breaking changes:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- Fractional seconds are cut off to microseconds (always round down)
- Allow control over return type of parse_duration #64 (Felix Claessen)


Expand Down
2 changes: 0 additions & 2 deletions MANIFEST.in

This file was deleted.

7 changes: 3 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ As this module maps ISO 8601 dates/times to standard Python data types, like
all possible ISO 8601 dates/times. For instance, dates before 0001-01-01 are
not allowed by the Python *date* and *datetime* classes. Additionally
fractional seconds are limited to microseconds. That means if the parser finds
for instance nanoseconds it will round it to microseconds.
for instance nanoseconds it will round it down to microseconds.

Documentation
-------------
Expand Down Expand Up @@ -88,8 +88,7 @@ Installation

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

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

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

Source code is available at `<http://github.com/gweis/isodate>`_.
Source code is available at `<https://github.com/gweis/isodate>`_.
60 changes: 60 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[project]
name = "isodate"
description = "An ISO 8601 date/time/duration parser and formatter"
# TODO: long_description = "file: README.rst, CHANGES.txt, TODO.txt"
# TODO: url = "https://github.com/gweis/isodate/"
authors = [{name="Gerhard Weis"}]
# keywords =
license = {file = "LICENSE"}
# license = {text="BSD-3-Clause"}
#TODO: license_files = "LICENSE"
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Internet",
"Topic :: Software Development :: Libraries :: Python Modules",
]
# requires-python = ">3.7"
dynamic = ["version"]


[build-system]
requires = ["setuptools", "setuptools_scm[toml]"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "src/isodate/version.py"
fallback_version = "0.0.0.dev0"


[tool.pytest.ini_options]
testpaths = ["tests"]
filterwarnings = [
# treat all warnings as errors
"error",
# ignore:<regexp>
# e.g.:
# ignore:jsonschema.RefResolver is deprecated as of v4.18.0
]
junit_family = "xunit2"

[tool.coverage.run]
source_pkgs = ["isodate"]
omit = ["tests/"]

[tool.black]
line-length = 88

[tool.isort]
profile = "black"
43 changes: 0 additions & 43 deletions setup.py

This file was deleted.

66 changes: 44 additions & 22 deletions src/isodate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,51 @@
This module contains also various pre-defined ISO 8601 format strings.
"""
from isodate.isodates import parse_date, date_isoformat
from isodate.isotime import parse_time, time_isoformat
from isodate.isodatetime import parse_datetime, datetime_isoformat
from isodate.isoduration import parse_duration, duration_isoformat

from isodate.duration import Duration
from isodate.isodates import date_isoformat, parse_date
from isodate.isodatetime import datetime_isoformat, parse_datetime
from isodate.isoduration import duration_isoformat, parse_duration
from isodate.isoerror import ISO8601Error
from isodate.isostrf import (
D_ALT_BAS,
D_ALT_BAS_ORD,
D_ALT_EXT,
D_ALT_EXT_ORD,
D_DEFAULT,
D_WEEK,
DATE_BAS_COMPLETE,
DATE_BAS_MONTH,
DATE_BAS_ORD_COMPLETE,
DATE_BAS_WEEK,
DATE_BAS_WEEK_COMPLETE,
DATE_CENTURY,
DATE_EXT_COMPLETE,
DATE_EXT_MONTH,
DATE_EXT_ORD_COMPLETE,
DATE_EXT_WEEK,
DATE_EXT_WEEK_COMPLETE,
DATE_YEAR,
DT_BAS_COMPLETE,
DT_BAS_ORD_COMPLETE,
DT_BAS_WEEK_COMPLETE,
DT_EXT_COMPLETE,
DT_EXT_ORD_COMPLETE,
DT_EXT_WEEK_COMPLETE,
TIME_BAS_COMPLETE,
TIME_BAS_MINUTE,
TIME_EXT_COMPLETE,
TIME_EXT_MINUTE,
TIME_HOUR,
TZ_BAS,
TZ_EXT,
TZ_HOUR,
strftime,
)
from isodate.isotime import parse_time, time_isoformat
from isodate.isotzinfo import parse_tzinfo, tz_isoformat
from isodate.tzinfo import UTC, FixedOffset, LOCAL
from isodate.duration import Duration
from isodate.isostrf import strftime
from isodate.isostrf import DATE_BAS_COMPLETE, DATE_BAS_ORD_COMPLETE
from isodate.isostrf import DATE_BAS_WEEK, DATE_BAS_WEEK_COMPLETE
from isodate.isostrf import DATE_CENTURY, DATE_EXT_COMPLETE
from isodate.isostrf import DATE_EXT_ORD_COMPLETE, DATE_EXT_WEEK
from isodate.isostrf import DATE_EXT_WEEK_COMPLETE, DATE_YEAR
from isodate.isostrf import DATE_BAS_MONTH, DATE_EXT_MONTH
from isodate.isostrf import TIME_BAS_COMPLETE, TIME_BAS_MINUTE
from isodate.isostrf import TIME_EXT_COMPLETE, TIME_EXT_MINUTE
from isodate.isostrf import TIME_HOUR
from isodate.isostrf import TZ_BAS, TZ_EXT, TZ_HOUR
from isodate.isostrf import DT_BAS_COMPLETE, DT_EXT_COMPLETE
from isodate.isostrf import DT_BAS_ORD_COMPLETE, DT_EXT_ORD_COMPLETE
from isodate.isostrf import DT_BAS_WEEK_COMPLETE, DT_EXT_WEEK_COMPLETE
from isodate.isostrf import D_DEFAULT, D_WEEK, D_ALT_EXT, D_ALT_BAS
from isodate.isostrf import D_ALT_BAS_ORD, D_ALT_EXT_ORD
from isodate.tzinfo import LOCAL, UTC, FixedOffset
from isodate.version import version as __version__

__all__ = [
"parse_date",
Expand Down Expand Up @@ -78,4 +99,5 @@
"D_ALT_BAS",
"D_ALT_BAS_ORD",
"D_ALT_EXT_ORD",
"__version__",
]
3 changes: 2 additions & 1 deletion src/isodate/duration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
The class Duration allows to define durations in years and months and can be
used as limited replacement for timedelta objects.
"""

from datetime import timedelta
from decimal import Decimal, ROUND_FLOOR
from decimal import ROUND_FLOOR, Decimal


def fquotmod(val, low, high):
Expand Down
3 changes: 2 additions & 1 deletion src/isodate/isodates.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
standard. The only limitations it has, are given by the Python datetime.date
implementation, which does not support dates before 0001-01-01.
"""

import re
from datetime import date, timedelta

from isodate.isostrf import strftime, DATE_EXT_COMPLETE
from isodate.isoerror import ISO8601Error
from isodate.isostrf import DATE_EXT_COMPLETE, strftime

DATE_REGEX_CACHE = {}
# A dictionary to cache pre-compiled regular expressions.
Expand Down
4 changes: 2 additions & 2 deletions src/isodate/isodatetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
For this job it uses the parse_date and parse_time methods defined in date
and time module.
"""

from datetime import datetime

from isodate.isostrf import strftime
from isodate.isostrf import DATE_EXT_COMPLETE, TIME_EXT_COMPLETE, TZ_EXT
from isodate.isodates import parse_date
from isodate.isoerror import ISO8601Error
from isodate.isostrf import DATE_EXT_COMPLETE, TIME_EXT_COMPLETE, TZ_EXT, strftime
from isodate.isotime import parse_time


Expand Down
7 changes: 4 additions & 3 deletions src/isodate/isoduration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
It also provides a wrapper to strftime. This wrapper makes it easier to
format timedelta or Duration instances as ISO conforming strings.
"""

import re
from datetime import timedelta
from decimal import Decimal
import re

from isodate.duration import Duration
from isodate.isoerror import ISO8601Error
from isodate.isodatetime import parse_datetime
from isodate.isostrf import strftime, D_DEFAULT
from isodate.isoerror import ISO8601Error
from isodate.isostrf import D_DEFAULT, strftime

ISO8601_PERIOD_REGEX = re.compile(
r"^(?P<sign>[+-])?"
Expand Down
Loading

0 comments on commit 2ace19f

Please sign in to comment.