Skip to content

Commit

Permalink
Merge pull request #209 from Fatal1ty/python-3.13
Browse files Browse the repository at this point in the history
Add support for Python 3.13
  • Loading branch information
Fatal1ty authored Apr 14, 2024
2 parents 8fff60d + 968fbd7 commit 0831913
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -42,7 +42,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Use pip to install:
$ pip install mashumaro
```

The current version of `mashumaro` supports Python versions 3.8 — 3.12.
The current version of `mashumaro` supports Python versions 3.8 — 3.13.


It's not recommended to use any version of Python that has reached its
Expand Down
5 changes: 4 additions & 1 deletion mashumaro/core/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"PY_310_MIN",
"PY_311_MIN",
"PY_312_MIN",
"PY_313_MIN",
"PEP_585_COMPATIBLE",
"Sentinel",
]
Expand All @@ -18,8 +19,10 @@
PY_39 = sys.version_info.major == 3 and sys.version_info.minor == 9
PY_310 = sys.version_info.major == 3 and sys.version_info.minor == 10
PY_311 = sys.version_info.major == 3 and sys.version_info.minor == 11
PY_312_MIN = sys.version_info.major == 3 and sys.version_info.minor >= 12
PY_312 = sys.version_info.major == 3 and sys.version_info.minor == 12
PY_313_MIN = sys.version_info.major == 3 and sys.version_info.minor >= 13

PY_312_MIN = PY_312 or PY_313_MIN
PY_311_MIN = PY_311 or PY_312_MIN
PY_310_MIN = PY_310 or PY_311_MIN
PY_39_MIN = PY_39 or PY_310_MIN
Expand Down
4 changes: 2 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ msgpack>=0.5.6
pyyaml>=3.13
tomli-w>=1.0
tomli>=1.1.0;python_version<'3.11'
orjson>=3.6.1
orjson>=3.6.1;python_version<'3.13'

# tests
mypy>=0.812
Expand All @@ -18,7 +18,7 @@ codespell>=2.2.2

# third party features
ciso8601>=2.1.3
pendulum>=2.1.2
pendulum>=2.1.2;python_version<'3.13'

# benchmark
pyperf>=2.6.1
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Development Status :: 5 - Production/Stable",
],
license="Apache License, Version 2.0",
Expand Down
11 changes: 11 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
from unittest.mock import patch

from mashumaro.core.const import PY_313_MIN

if PY_313_MIN:
collect_ignore = [
"test_codecs/test_orjson_codec.py",
"test_discriminated_unions/test_dialects.py",
"test_orjson.py",
"test_pep_563.py",
"test_self.py",
]

add_unpack_method = patch(
"mashumaro.core.meta.code.builder.CodeBuilder.add_unpack_method",
lambda *args, **kwargs: ...,
Expand Down
5 changes: 2 additions & 3 deletions tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,8 @@ def __init__(self, number):
instance = cls(1)
with pytest.raises(AttributeError) as e:
instance.new_attribute = 2
assert (
str(e.value)
== f"'{cls.__name__}' object has no attribute 'new_attribute'"
assert str(e.value).startswith(
f"'{cls.__name__}' object has no attribute 'new_attribute'"
)


Expand Down
5 changes: 4 additions & 1 deletion tests/test_metadata_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import pytest

from mashumaro import DataClassDictMixin
from mashumaro.core.const import PY_312_MIN
from mashumaro.core.const import PY_312_MIN, PY_313_MIN
from mashumaro.exceptions import (
UnserializableField,
UnsupportedDeserializationEngine,
Expand Down Expand Up @@ -58,6 +58,7 @@ class DataClass(DataClassDictMixin):
assert instance == should_be


@pytest.mark.skipif(PY_313_MIN, reason="pendulum doesn't install on 3.13")
def test_pendulum_datetime_parser():
@dataclass
class DataClass(DataClassDictMixin):
Expand All @@ -68,6 +69,7 @@ class DataClass(DataClassDictMixin):
assert instance == should_be


@pytest.mark.skipif(PY_313_MIN, reason="pendulum doesn't install on 3.13")
def test_pendulum_date_parser():
@dataclass
class DataClass(DataClassDictMixin):
Expand All @@ -78,6 +80,7 @@ class DataClass(DataClassDictMixin):
assert instance == should_be


@pytest.mark.skipif(PY_313_MIN, reason="pendulum doesn't install on 3.13")
def test_pendulum_time_parser():
@dataclass
class DataClass(DataClassDictMixin):
Expand Down

0 comments on commit 0831913

Please sign in to comment.