Skip to content

Commit b438f8c

Browse files
author
Michael Schneeberger
committed
adapt dataclass_abc to dataclass of python 3.10
1 parent 402e1e9 commit b438f8c

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

dataclass_abc/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from dataclasses import _init_fn # type: ignore
66
from dataclasses import _set_new_attribute # type: ignore
77
from dataclasses import dataclass as parent_dataclass, MISSING
8+
from dataclasses import _fields_in_init_order
89
from typing import Generator, Tuple, Any, TypeVar
910

1011
T = TypeVar('T')
@@ -102,13 +103,14 @@ def gen_fields():
102103

103104
yield field
104105

105-
flds = list(gen_fields())
106+
all_init_fields = list(gen_fields())
107+
(std_init_fields, kw_only_init_fields) = _fields_in_init_order(all_init_fields)
106108

107109
# Does this class have a post-init function?
108110
has_post_init = hasattr(cls, _POST_INIT_NAME)
109111

110112
_set_new_attribute(cls, '__init__',
111-
_init_fn(flds,
113+
_init_fn(all_init_fields, std_init_fields, kw_only_init_fields,
112114
frozen,
113115
has_post_init,
114116
# The name to use for the "self"

setup.py

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

1111
setup(
1212
name='dataclass_abc',
13-
version='0.0.4',
13+
version='0.0.5',
1414
description='Library that lets you define abstract properties for dataclasses.',
1515
long_description=long_description,
1616
long_description_content_type='text/markdown',
@@ -19,10 +19,9 @@
1919
author_email='michael.schneeb@outlook.com',
2020
classifiers=[
2121
'License :: OSI Approved :: MIT License',
22-
'Programming Language :: Python :: 3.7',
23-
'Programming Language :: Python :: 3.8',
22+
'Programming Language :: Python :: 3.10',
2423
],
2524
keywords='dataclass_abc abstract abc property',
2625
packages=['dataclass_abc'],
27-
python_requires='>=3.7',
26+
python_requires='>=3.10',
2827
)

0 commit comments

Comments
 (0)