Skip to content

Commit 05d9be1

Browse files
authored
fix: Test failures with Python 3.13.0a4: test_dates_behave_like_dates and test_times_behave_like_times (#349)
Fixes #333 Signed-off-by: Frost Ming <[email protected]>
1 parent a96883b commit 05d9be1

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
os: [ubuntu-latest, macos-13, windows-latest]
20-
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", 3.12]
20+
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", 3.12, 3.13]
2121

2222
steps:
2323
- uses: actions/checkout@v4
@@ -28,6 +28,7 @@ jobs:
2828
uses: actions/setup-python@v5
2929
with:
3030
python-version: ${{ matrix.python-version }}
31+
allow-prereleases: true
3132

3233
- name: Get full python version
3334
id: full-python-version

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log
22

3+
## [unreleased]
4+
5+
### Fixed
6+
7+
- Fix the incompatiblity with 3.13 because of the `datetime.replace()` change. ([#333](https://github.com/python-poetry/tomlkit/issues/333))
8+
39
## [0.12.4] - 2024-05-08
410

511
### Fixed

tests/test_items.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,15 +689,15 @@ def test_dates_behave_like_dates():
689689
assert i.as_string() == "2018-07-22"
690690

691691
i += timedelta(days=1)
692-
assert i == datetime(2018, 7, 23)
692+
assert i == date(2018, 7, 23)
693693
assert i.as_string() == "2018-07-23"
694694

695695
i -= timedelta(days=2)
696696
assert i == date(2018, 7, 21)
697697
assert i.as_string() == "2018-07-21"
698698

699699
i = i.replace(year=2019)
700-
assert i == datetime(2019, 7, 21)
700+
assert i == date(2019, 7, 21)
701701
assert i.as_string() == "2019-07-21"
702702

703703
doc = parse("dt = 2018-07-22 # Comment")

tomlkit/items.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -958,9 +958,14 @@ def __new__(cls, year: int, month: int, day: int, *_: Any) -> date:
958958
return date.__new__(cls, year, month, day)
959959

960960
def __init__(
961-
self, year: int, month: int, day: int, trivia: Trivia, raw: str
961+
self,
962+
year: int,
963+
month: int,
964+
day: int,
965+
trivia: Trivia | None = None,
966+
raw: str = "",
962967
) -> None:
963-
super().__init__(trivia)
968+
super().__init__(trivia or Trivia())
964969

965970
self._raw = raw
966971

@@ -1033,10 +1038,10 @@ def __init__(
10331038
second: int,
10341039
microsecond: int,
10351040
tzinfo: tzinfo | None,
1036-
trivia: Trivia,
1037-
raw: str,
1041+
trivia: Trivia | None = None,
1042+
raw: str = "",
10381043
) -> None:
1039-
super().__init__(trivia)
1044+
super().__init__(trivia or Trivia())
10401045

10411046
self._raw = raw
10421047

0 commit comments

Comments
 (0)