Skip to content

Commit 9281dc7

Browse files
authored
Merge pull request #30 from robabram/ra/version-update
Update supported Python versions
2 parents 7cdbfd3 + 71baaae commit 9281dc7

6 files changed

Lines changed: 23 additions & 16 deletions

File tree

.github/workflows/coverage.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v3
11-
- name: Set up Python 3.12
11+
- name: Set up Python 3.13
1212
uses: actions/setup-python@v4
1313
with:
14-
python-version: 3.12
14+
python-version: 3.13
1515
- name: Install Dependencies
1616
run: |
1717
python -m pip install --upgrade pip

.github/workflows/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
11+
python-version: ["3.8.18", "3.9.25", "3.10.18", "3.11.14", "3.12.12", "3.13.11", "3.14.2"]
1212

1313
steps:
1414
- uses: actions/checkout@v3

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
line-length = 120
2-
target-version = ['py37', 'py38', 'py39', 'py310']
2+
target-version = ['py37', 'py38', 'py39', 'py310', 'py311', 'py312', 'py313', 'py314']

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from setuptools import setup, find_packages
88

9-
__VERSION__ = "1.2.0"
9+
__VERSION__ = "1.2.2"
1010

1111
base_dir = os.path.abspath(os.path.dirname(__file__))
1212

@@ -49,19 +49,20 @@
4949
"models",
5050
"data"
5151
],
52-
python_requires=">=3.6",
52+
python_requires=">=3.7",
5353
classifiers=[
5454
"Development Status :: 5 - Production/Stable",
5555
"Intended Audience :: Developers",
5656
"License :: OSI Approved :: MIT License",
5757
"Programming Language :: Python :: 3",
58-
"Programming Language :: Python :: 3.6",
5958
"Programming Language :: Python :: 3.7",
6059
"Programming Language :: Python :: 3.8",
6160
"Programming Language :: Python :: 3.9",
6261
"Programming Language :: Python :: 3.10",
6362
"Programming Language :: Python :: 3.11",
6463
"Programming Language :: Python :: 3.12",
64+
"Programming Language :: Python :: 3.13",
65+
"Programming Language :: Python :: 3.14",
6566
],
6667
test_suite="tests",
6768
project_urls={

src/python_easy_json/json_object.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
from dateutil import parser as dt_parser
1414
from json import JSONDecodeError
1515

16+
# 3.14 introduced lazy annotation loading, we must use the 'annotationlib' to inspect annotations.
17+
if not (sys.version_info.major == 3 and sys.version_info.minor < 14):
18+
from annotationlib import get_annotations, Format as annot_format
19+
1620
_enum_t = type(enum.Enum)
1721

1822
# Support OrderedDict for Python versions 3.6 or below.
@@ -45,8 +49,8 @@ def _get_annot_cls(annots: dict, key: str, ignore_builtins = False) -> typing.Li
4549
cls_ = cls_.__args__[0]
4650
# Check if typing annotation class is a Union type.
4751
# Try to find the right object class in the Union types list, ignore 'builtin' types.
48-
if '__args__' in cls_.__dict__ and isinstance(cls_.__dict__['__args__'], (list, tuple)):
49-
for cls_item in cls_.__dict__['__args__']:
52+
if hasattr(cls_, '__args__') and isinstance(cls_.__args__, (list, tuple)):
53+
for cls_item in cls_.__args__:
5054
# Try to find the right object class in the Union types list, ignore 'builtin' types.
5155
if issubclass(type(cls_item), object) and not isinstance(cls_item, typing.TypeVar):
5256
if ignore_builtins and cls_item.__module__ == 'builtins':
@@ -75,10 +79,12 @@ def _collect_annotations(self, cls_: object):
7579
continue
7680
result = self._collect_annotations(base)
7781
annots.update(result)
78-
79-
if hasattr(cls_, '__annotations__'):
80-
annots.update(cls_.__annotations__)
81-
82+
# 3.14 introduced breaking changes to annotation inspection due to lazy annotation loading.
83+
if sys.version_info.major == 3 and sys.version_info.minor < 14:
84+
if hasattr(cls_, '__annotations__'):
85+
annots.update(cls_.__annotations__)
86+
else:
87+
annots.update(get_annotations(cls_, format=annot_format.VALUE))
8288
return annots
8389

8490
@staticmethod

tests/test_json_with_enum.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This file is subject to the terms and conditions defined in the
33
# file 'LICENSE', which is part of this source code package.
44
#
5-
from datetime import datetime
5+
from datetime import datetime, timezone
66
from enum import Enum, IntEnum
77

88
from tests.base_test import BaseTestCase
@@ -45,7 +45,7 @@ class TestJSONWithEnum(BaseTestCase):
4545

4646
def test_object_with_enum_values(self):
4747
""" Test JSONObject class with IntEnum property. """
48-
ts = datetime.utcnow()
48+
ts = datetime.now(timezone.utc)
4949

5050
data = {
5151
'timestamp': ts.isoformat(),
@@ -69,7 +69,7 @@ def test_object_with_enum_values(self):
6969

7070
def test_str_enum(self):
7171
""" Test an enum with string values """
72-
ts = datetime.utcnow()
72+
ts = datetime.now(timezone.utc)
7373

7474
data = {
7575
'timestamp': ts.isoformat(),

0 commit comments

Comments
 (0)