Skip to content

Commit 2ef5a71

Browse files
committed
Add python 3.13
1 parent 231b3b2 commit 2ef5a71

File tree

6 files changed

+49
-14
lines changed

6 files changed

+49
-14
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
os: ["ubuntu-latest"]
15-
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.10"]
15+
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.10"]
1616

1717
runs-on: ${{ matrix.os }}
1818
steps:

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ repos:
1717
- id: flake8
1818
additional_dependencies: ['flake8-bugbear==22.10.27']
1919
- repo: https://github.com/pre-commit/mirrors-mypy
20-
rev: v1.1.1
20+
rev: v1.13.0
2121
hooks:
2222
- id: mypy
2323
additional_dependencies: [typeguard,marshmallow]

marshmallow_dataclass/generic_resolver.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,15 @@ def get_generic_dataclass_fields(clazz: type) -> Tuple[dataclasses.Field, ...]:
236236
# Either the first time we see this field, or it got overridden
237237
# If it's a class we handle it later as a Nested. Nothing to resolve now.
238238
new_field = field
239-
if not inspect.isclass(field.type) and may_contain_typevars(field.type):
239+
field_type: type = field.type # type: ignore[assignment]
240+
if not inspect.isclass(field_type) and may_contain_typevars(field_type):
240241
new_field = copy.copy(field)
241242
new_field.type = _replace_typevars(
242-
field.type, resolved_typevars[subclass]
243+
field_type, resolved_typevars[subclass]
243244
)
244-
elif isinstance(field.type, TypeVar):
245+
elif isinstance(field_type, TypeVar):
245246
new_field = copy.copy(field)
246-
new_field.type = resolved_typevars[subclass][field.type].result()
247+
new_field.type = resolved_typevars[subclass][field_type].result()
247248

248249
fields[field.name] = (field, new_field)
249250
except InvalidStateError:

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"Programming Language :: Python :: 3.10",
1414
"Programming Language :: Python :: 3.11",
1515
"Programming Language :: Python :: 3.12",
16+
"Programming Language :: Python :: 3.13",
1617
"Topic :: Internet :: WWW/HTTP :: Dynamic Content :: CGI Tools/Libraries",
1718
]
1819

tests/test_generics.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,16 @@ class TestClass(typing.Generic[T, U, V]):
210210
override: int
211211

212212
# Don't only override typevar, but switch order to further confuse things
213+
# Ignoring 'override' Because I want to test that it works, even if incompatible types
213214
@dataclasses.dataclass
214-
class TestClass2(TestClass[str, W, U]):
215-
override: str # type: ignore # Want to test that it works, even if incompatible types
215+
class TestClass2(TestClass[str, W, U]): # type: ignore[override]
216+
override: str # type: ignore[override, assignment]
216217

217-
TestAlias = TestClass2[int, T]
218+
TestAlias = TestClass2[int, T] # type: ignore[override]
218219

219220
# inherit from alias
220221
@dataclasses.dataclass
221-
class TestClass3(TestAlias[typing.List[int]]):
222+
class TestClass3(TestAlias[typing.List[int]]): # type: ignore[override]
222223
pass
223224

224225
test_schema = class_schema(TestClass3)()
@@ -430,10 +431,11 @@ class TestClass(typing.Generic[T, U, V]):
430431

431432
# Don't only override typevar, but switch order to further confuse things
432433
@dataclasses.dataclass
433-
class TestClass2(TestClass[str, W, U]):
434-
override: str # type: ignore # Want to test that it works, even if incompatible types
434+
class TestClass2(TestClass[str, W, U]): # type: ignore[override]
435+
# Want to test that it works, even if incompatible types
436+
override: str # type: ignore[override, assignment]
435437

436-
TestAlias = TestClass2[int, T]
438+
TestAlias = TestClass2[int, T] # type: ignore[override]
437439
test_schema2 = class_schema(TestClass2)()
438440
assert list(test_schema2.fields) == ["pairs", "gen", "override"]
439441
assert isinstance(test_schema2.fields["pairs"], marshmallow.fields.List)
@@ -452,7 +454,7 @@ class TestClass2(TestClass[str, W, U]):
452454

453455
# inherit from alias
454456
@dataclasses.dataclass
455-
class TestClass3(TestAlias[typing.List[int]]):
457+
class TestClass3(TestAlias[typing.List[int]]): # type: ignore[override]
456458
pass
457459

458460
test_schema3 = class_schema(TestClass3)()

tox.ini

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[tox]
2+
requires =
3+
tox>=4
4+
virtualenv-pyenv
5+
env_list =
6+
py{38,39,310,311,312,313}
7+
cover-report
8+
set_env =
9+
VIRTUALENV_DISCOVERY = pyenv
10+
11+
[testenv]
12+
deps =
13+
coverage
14+
pytest
15+
commands = coverage run -p -m pytest tests
16+
extras = dev
17+
set_env =
18+
VIRTUALENV_DISCOVERY = pyenv
19+
depends =
20+
cover-report: py{38,39,310,311,312,313}
21+
22+
[testenv:cover-report]
23+
skip_install = true
24+
deps = coverage
25+
commands =
26+
coverage combine
27+
coverage html
28+
coverage report
29+
30+
31+
# - You can also run `tox` from the command line to test in all supported python versions. Note that this will require you to have all supported python versions installed.

0 commit comments

Comments
 (0)