Skip to content
Merged
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
11 changes: 7 additions & 4 deletions .github/workflows/code_changes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ jobs:
permissions:
contents: "read"
id-token: "write"
strategy:
fail-fast: false
matrix:
python-version: ['3.13', '3.14']
steps:
- name: Checkout repo
uses: actions/checkout@v4
Expand All @@ -37,14 +41,13 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'

python-version: ${{ matrix.python-version }}
allow-prereleases: true

- name: Install package
run: uv pip install -e .[dev] --system
- name: Install JB
run: uv pip install "jupyter-book>=2.0.0a0" --system
- name: UV sync
run: uv sync
- name: Run tests with coverage
run: make test
env:
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/pr_code_changes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ jobs:
run: ruff check .
Test:
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.13', '3.14']
steps:
- name: Checkout repo
uses: actions/checkout@v4
Expand All @@ -34,14 +38,13 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'

python-version: ${{ matrix.python-version }}
allow-prereleases: true

- name: Install package
run: uv pip install -e .[dev] --system
- name: Install policyengine
run: uv pip install policyengine --system
- name: UV sync
run: uv sync
- name: Run tests with coverage
run: make test
env:
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.14
4 changes: 4 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- bump: minor
changes:
added:
- Python 3.14 support
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ authors = [
]
license = {file = "LICENSE"}
requires-python = ">=3.13"
classifiers = [
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
]
dependencies = [
"pydantic>=2.0.0",
"pandas>=2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions src/policyengine/outputs/aggregate.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from enum import Enum
from enum import StrEnum
from typing import Any

from policyengine.core import Output, Simulation


class AggregateType(str, Enum):
class AggregateType(StrEnum):
SUM = "sum"
MEAN = "mean"
COUNT = "count"
Expand Down
4 changes: 2 additions & 2 deletions src/policyengine/outputs/change_aggregate.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from enum import Enum
from enum import StrEnum
from typing import Any

from policyengine.core import Output, Simulation


class ChangeAggregateType(str, Enum):
class ChangeAggregateType(StrEnum):
COUNT = "count"
SUM = "sum"
MEAN = "mean"
Expand Down
6 changes: 3 additions & 3 deletions src/policyengine/outputs/poverty.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Poverty analysis output types."""

from enum import Enum
from enum import StrEnum
from typing import Any

import pandas as pd
Expand All @@ -9,7 +9,7 @@
from policyengine.core import Output, OutputCollection, Simulation


class UKPovertyType(str, Enum):
class UKPovertyType(StrEnum):
"""UK poverty measure types."""

ABSOLUTE_BHC = "absolute_bhc"
Expand All @@ -18,7 +18,7 @@ class UKPovertyType(str, Enum):
RELATIVE_AHC = "relative_ahc"


class USPovertyType(str, Enum):
class USPovertyType(StrEnum):
"""US poverty measure types."""

SPM = "spm"
Expand Down
7 changes: 6 additions & 1 deletion src/policyengine/utils/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ def parse_safe_date(date_string: str) -> datetime:
return date_obj
except ValueError as e:
# Try to handle invalid day values (e.g., 2021-06-31)
if "day is out of range for month" in str(e):
# Python <3.14: "day is out of range for month"
# Python 3.14+: "day N must be in range 1..M for month ..."
error_msg = str(e)
if "day is out of range for month" in error_msg or (
"must be in range" in error_msg and "for month" in error_msg
):
parts = date_string.split("-")
if len(parts) == 3:
year = int(parts[0])
Expand Down