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
18 changes: 9 additions & 9 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: '3.11'
Expand All @@ -44,7 +44,7 @@ jobs:
continue-on-error: ${{ matrix.python-version == '3.15-dev' }}

steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
Expand All @@ -62,7 +62,7 @@ jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: '3.x'
Expand All @@ -89,7 +89,7 @@ jobs:
os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, windows-11-arm, macos-latest]

steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6

- uses: actions/setup-python@v6
with:
Expand All @@ -101,12 +101,12 @@ jobs:
python scripts/use_setuptools.py

- name: Build wheels
uses: pypa/cibuildwheel@v3.2.0
uses: pypa/cibuildwheel@v3.3.1
env:
CIBW_ARCHS_MACOS: x86_64 arm64
TOMLI_USE_MYPYC: '1'

- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v6
with:
name: artifact-binary-${{ matrix.os }}
path: wheelhouse/*.whl
Expand All @@ -117,15 +117,15 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6

- name: Install build dependencies
run: pip install build

- name: Build
run: python -m build

- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v6
with:
name: artifact-pure-python
path: dist/*
Expand All @@ -148,7 +148,7 @@ jobs:
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v5
- uses: actions/download-artifact@v7
with:
path: dist
pattern: artifact-*
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
files: '^src/.+\.py$|^tests/.+\.py$'
args: ['--license-filepath', 'LICENSE-HEADER']
- repo: https://github.com/executablebooks/mdformat
rev: ff29be1a1ba8029d9375882aa2c812b62112a593 # frozen: 0.7.22
rev: 2d496dbc18e31b83a1596685347ffe0b6041daf0 # frozen: 1.0.0
hooks:
- id: mdformat
additional_dependencies:
Expand All @@ -28,11 +28,11 @@ repos:
files: '^src/.+\.py$'
args: ['--never', '--application-directories', 'src']
- repo: https://github.com/PyCQA/isort
rev: ec0efaee4acfce198521e43caa3029b06cedd64a # frozen: 6.1.0
rev: 0a09c783808cfe77bb3269250f663ff733d23302 # frozen: 7.0.0
hooks:
- id: isort
- repo: https://github.com/psf/black-pre-commit-mirror
rev: fe95161893684893d68b1225356702ca71f8d388 # frozen: 25.9.0
rev: 831207fd435b47aeffdf6af853097e64322b4d44 # frozen: 25.12.0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -54,7 +54,7 @@ repos:
- flake8-builtins
- flake8-comprehensions
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 9f70dc58c23dfcca1b97af99eaeee3140a807c7e # frozen: v1.18.2
rev: a66e98df7b4aeeb3724184b332785976d062b92e # frozen: v1.19.1
hooks:
- id: mypy
args: ["--scripts-are-modules"]
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 2.4.0

- Added
- TOML v1.1.0 compatibility
- Binary wheels for Windows arm64

## 2.3.0

- Added
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
## Intro<a name="intro"></a>

Tomli is a Python library for parsing [TOML](https://toml.io).
It is fully compatible with [TOML v1.0.0](https://toml.io/en/v1.0.0).
Version 2.4.0 and later are compatible with [TOML v1.1.0](https://toml.io/en/v1.1.0).
Older versions are [TOML v1.0.0](https://toml.io/en/v1.0.0) compatible.

A version of Tomli, the `tomllib` module,
was added to the standard library in Python 3.11
Expand Down Expand Up @@ -159,7 +160,7 @@ tomllib.loads("['This parses fine with Python 3.6+']")
2.1x as fast as [toml](https://pypi.org/project/toml/)
- outputs [basic data types](#how-do-toml-types-map-into-python-types) only
- 100% spec compliant: passes all tests in
[BurntSushi/toml-test](https://github.com/BurntSushi/toml-test)
[toml-lang/toml-test](https://github.com/toml-lang/toml-test)
test suite
- thoroughly tested: 100% branch coverage

Expand Down
29 changes: 6 additions & 23 deletions tests/burntsushi.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,6 @@
import datetime
from typing import Any

# Aliases for converting TOML compliance format [1] to BurntSushi format [2]
# [1] https://github.com/toml-lang/compliance/blob/db7c3211fda30ff9ddb10292f4aeda7e2e10abc4/docs/json-encoding.md # noqa: E501
# [2] https://github.com/BurntSushi/toml-test/blob/4634fdf3a6ecd6aaea5f4cdcd98b2733c2694993/README.md # noqa: E501
_aliases = {
"boolean": "bool",
"offset datetime": "datetime",
"local datetime": "datetime-local",
"local date": "date-local",
"local time": "time-local",
}


def convert(obj):
if isinstance(obj, str):
Expand Down Expand Up @@ -53,31 +42,25 @@ def convert(obj):
def normalize(obj: Any) -> Any:
"""Normalize test objects.

This normalizes primitive values (e.g. floats), and also converts from
TOML compliance format [1] to BurntSushi format [2].

[1] https://github.com/toml-lang/compliance/blob/db7c3211fda30ff9ddb10292f4aeda7e2e10abc4/docs/json-encoding.md # noqa: E501
[2] https://github.com/BurntSushi/toml-test/blob/4634fdf3a6ecd6aaea5f4cdcd98b2733c2694993/README.md # noqa: E501
"""
This normalizes primitive values (e.g. floats)."""
if isinstance(obj, list):
return [normalize(item) for item in obj]
if isinstance(obj, dict):
if "type" in obj and "value" in obj:
type_ = obj["type"]
norm_type = _aliases.get(type_, type_)
value = obj["value"]
if norm_type == "float":
if type_ == "float":
norm_value = _normalize_float_str(value)
elif norm_type in {"datetime", "datetime-local"}:
elif type_ in {"datetime", "datetime-local"}:
norm_value = _normalize_datetime_str(value)
elif norm_type == "time-local":
elif type_ == "time-local":
norm_value = _normalize_localtime_str(value)
else:
norm_value = value

if norm_type == "array":
if type_ == "array":
return [normalize(item) for item in value]
return {"type": norm_type, "value": norm_value}
return {"type": type_, "value": norm_value}
return {k: normalize(v) for k, v in obj.items()}
raise AssertionError("Burntsushi fixtures should be dicts/lists only")

Expand Down