From 900c4d92a0da08bab0ce6114abb686786486402e Mon Sep 17 00:00:00 2001 From: Ritvik Nag Date: Tue, 5 Nov 2024 07:15:07 -0500 Subject: [PATCH] Add compat for PY 3.13 --- .github/workflows/dev.yml | 2 +- CONTRIBUTING.rst | 2 +- HISTORY.rst | 17 +++++++++++++++++ dataclass_wizard/utils/typing_compat.py | 16 ++++++++++------ setup.py | 1 + tox.ini | 3 ++- 6 files changed, 32 insertions(+), 9 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index f3f8a553..b7ff9139 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -18,7 +18,7 @@ jobs: # The type of runner that the job will run on strategy: matrix: - python-versions: [3.6, 3.7, 3.8, 3.9, '3.10', '3.11', '3.12'] + python-versions: [3.6, 3.7, 3.8, 3.9, '3.10', '3.11', '3.12', '3.13'] os: [ubuntu-20.04] # Uncomment if I need to run it on other environments too (currently # there's not a huge need) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 5783bb7f..c83ccf88 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -107,7 +107,7 @@ Before you submit a pull request, check that it meets these guidelines: 2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst. -3. The pull request should work for Python 3.6, 3.7, 3.8, 3.9, 3.10, 3.11 and 3.12, and for PyPy. Check +3. The pull request should work for Python 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12 and 3.13, and for PyPy. Check https://github.com/rnag/dataclass-wizard/actions/workflows/dev.yml and make sure that the tests pass for all supported Python versions. diff --git a/HISTORY.rst b/HISTORY.rst index 077ff49a..9b900fa1 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -2,6 +2,23 @@ History ======= +0.26.0 (2024-11-05) +------------------- + +* This will be the latest (minor) release with support for Python 3.6, 3.7, and 3.8 -- + all of which have reached *end-of-life*! + +**Features and Improvements** + +* Add compatability and support for **Python 3.13**. Thanks to :user:`benjjs` in :pr:`129`! + +**Bugfixes** + +* Fix: :meth:`LiteralParser.__contains__` method compares value of item with `Literal`_ arguments. + Contributed by :user:`mikeweltevrede` in :pr:`111`. + +.. _Literal: https://docs.python.org/3/library/typing.html#typing.Literal + 0.25.0 (2024-11-03) ------------------- diff --git a/dataclass_wizard/utils/typing_compat.py b/dataclass_wizard/utils/typing_compat.py index 10a9bb6a..ec926942 100644 --- a/dataclass_wizard/utils/typing_compat.py +++ b/dataclass_wizard/utils/typing_compat.py @@ -16,6 +16,7 @@ 'eval_forward_ref_if_needed' ] +import functools import sys import types import typing @@ -351,6 +352,14 @@ def is_annotated(cls): return _is_annotated(cls) +if PY313_OR_ABOVE: + # noinspection PyProtectedMember,PyUnresolvedReferences + _eval_type = functools.partial(typing._eval_type, type_params=()) +else: + # noinspection PyProtectedMember,PyUnresolvedReferences + _eval_type = typing._eval_type + + def eval_forward_ref(base_type: FREF, cls: typing.Type): """ @@ -364,12 +373,7 @@ def eval_forward_ref(base_type: FREF, # Evaluate the ForwardRef here base_globals = sys.modules[cls.__module__].__dict__ - if PY313_OR_ABOVE: - # noinspection PyProtectedMember - return typing._eval_type(base_type, base_globals, _TYPING_LOCALS, type_params=()) - else: - # noinspection PyProtectedMember - return typing._eval_type(base_type, base_globals, _TYPING_LOCALS) + return _eval_type(base_type, base_globals, _TYPING_LOCALS) def eval_forward_ref_if_needed(base_type: typing.Union[typing.Type, FREF], diff --git a/setup.py b/setup.py index f4c80724..dd34912c 100644 --- a/setup.py +++ b/setup.py @@ -94,6 +94,7 @@ 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', + 'Programming Language :: Python :: 3.13', 'Programming Language :: Python' ], test_suite='tests', diff --git a/tox.ini b/tox.ini index b3c567ca..b451fbb6 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,9 @@ [tox] -envlist = py36, py37, py38, py39, py310, py311, py312, flake8 +envlist = py36, py37, py38, py39, py310, py311, py312, py313, flake8 [gh-actions] python = + 3.13: py313 3.12: py312 3.11: py311 3.10: py310