Skip to content

Commit

Permalink
fix: Test failures with Python 3.13.0a4: test_dates_behave_like_dates…
Browse files Browse the repository at this point in the history
… and test_times_behave_like_times (#349)

Fixes #333

Signed-off-by: Frost Ming <me@frostming.com>
  • Loading branch information
frostming authored May 13, 2024
1 parent a96883b commit 05d9be1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13, windows-latest]
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", 3.12]
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", 3.12, 3.13]

steps:
- uses: actions/checkout@v4
Expand All @@ -28,6 +28,7 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true

- name: Get full python version
id: full-python-version
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## [unreleased]

### Fixed

- Fix the incompatiblity with 3.13 because of the `datetime.replace()` change. ([#333](https://github.com/python-poetry/tomlkit/issues/333))

## [0.12.4] - 2024-05-08

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions tests/test_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,15 +689,15 @@ def test_dates_behave_like_dates():
assert i.as_string() == "2018-07-22"

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

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

i = i.replace(year=2019)
assert i == datetime(2019, 7, 21)
assert i == date(2019, 7, 21)
assert i.as_string() == "2019-07-21"

doc = parse("dt = 2018-07-22 # Comment")
Expand Down
15 changes: 10 additions & 5 deletions tomlkit/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,9 +958,14 @@ def __new__(cls, year: int, month: int, day: int, *_: Any) -> date:
return date.__new__(cls, year, month, day)

def __init__(
self, year: int, month: int, day: int, trivia: Trivia, raw: str
self,
year: int,
month: int,
day: int,
trivia: Trivia | None = None,
raw: str = "",
) -> None:
super().__init__(trivia)
super().__init__(trivia or Trivia())

self._raw = raw

Expand Down Expand Up @@ -1033,10 +1038,10 @@ def __init__(
second: int,
microsecond: int,
tzinfo: tzinfo | None,
trivia: Trivia,
raw: str,
trivia: Trivia | None = None,
raw: str = "",
) -> None:
super().__init__(trivia)
super().__init__(trivia or Trivia())

self._raw = raw

Expand Down

0 comments on commit 05d9be1

Please sign in to comment.