Skip to content
Open
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
8 changes: 4 additions & 4 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
strategy:
max-parallel: 8
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev", "pypy3.10"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.10"]

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

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
Expand All @@ -32,7 +32,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
Expand All @@ -46,7 +46,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
# To update: run `pre-commit autoupdate`
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-added-large-files
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.6.8
rev: v0.9.8
hooks:
- id: ruff
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.2
rev: v1.15.0
hooks:
- id: mypy
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]
### Changed
- Drop support for Python3.8
- Switch completely to [just](https://just.systems/) for development tasts, remove nox. Rely on Github actions matrix of python versions for testing across all supported python versions.
- Remove black, rely on ruff for formatting.

Expand Down
16 changes: 8 additions & 8 deletions iso8601/iso8601.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
>>>

"""
from __future__ import annotations

import datetime
import re
import typing
from decimal import Decimal

__all__ = ["parse_date", "ParseError", "UTC", "FixedOffset"]
Expand Down Expand Up @@ -77,19 +77,19 @@ def FixedOffset(


def parse_timezone(
matches: typing.Dict[str, str],
default_timezone: typing.Optional[datetime.timezone] = UTC,
) -> typing.Optional[datetime.timezone]:
matches: dict[str, str],
default_timezone: datetime.timezone | None = UTC,
) -> datetime.timezone | None:
"""Parses ISO 8601 time zone specs into tzinfo offsets"""
tz = matches.get("timezone", None)
tz = matches.get("timezone")
if tz == "Z":
return UTC
# This isn't strictly correct, but it's common to encounter dates without
# timezones so I'll assume the default (which defaults to UTC).
# Addresses issue 4.
if tz is None:
return default_timezone
sign = matches.get("tz_sign", None)
sign = matches.get("tz_sign")
hours = int(matches.get("tz_hour", 0))
minutes = int(matches.get("tz_minute", 0))
description = f"{sign}{hours:02d}:{minutes:02d}"
Expand All @@ -100,7 +100,7 @@ def parse_timezone(


def parse_date(
datestring: str, default_timezone: typing.Optional[datetime.timezone] = UTC
datestring: str, default_timezone: datetime.timezone | None = UTC
) -> datetime.datetime:
"""Parses ISO 8601 dates into datetime objects

Expand Down Expand Up @@ -128,7 +128,7 @@ def parse_date(

# Drop any Nones from the regex matches
# TODO: check if there's a way to omit results in regexes
groups: typing.Dict[str, str] = {
groups: dict[str, str] = {
k: v for k, v in m.groupdict().items() if v is not None
}

Expand Down
Loading