Skip to content

Commit e5c817b

Browse files
committed
Remove the now unecessary explicit call to __post_init__
1 parent dab5c11 commit e5c817b

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

distutils/_dataclass.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def lenient_dataclass(**dc_kwargs):
2424

2525
@wraps(dataclass)
2626
def _wrap(cls: _T) -> _T:
27-
cls = dataclass(**dc_kwargs)(cls) # type: ignore[misc]
27+
cls = dataclass(**dc_kwargs)(cls)
2828
# Allowed field names in order
2929
safe = tuple(f.name for f in fields(cls))
3030
orig_init = cls.__init__
@@ -42,8 +42,7 @@ def _wrapped_init(self, *args, **kwargs):
4242
# Ensure default values (e.g. []) are used instead of None:
4343
positional = {k: v for k, v in zip(safe, args) if v is not None}
4444
keywords = {k: v for k, v in kwargs.items() if v is not None}
45-
orig_init(self, **positional, **keywords)
46-
self.__post_init__() # does not seem to be called when customizing __init__
45+
return orig_init(self, **positional, **keywords)
4746

4847
cls.__init__ = _wrapped_init
4948
return cls

distutils/tests/test_extension.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ def test_read_setup_file(self):
6464

6565
def test_extension_init(self):
6666
# the first argument, which is the name, must be a string
67-
with pytest.raises(TypeError):
67+
with pytest.raises(TypeError, match="'name' must be a string"):
6868
Extension(1, [])
6969
ext = Extension('name', [])
7070
assert ext.name == 'name'
7171

7272
# the second argument, which is the list of files, must
7373
# be an iterable of strings or PathLike objects, and not a string
74-
with pytest.raises(TypeError):
74+
with pytest.raises(TypeError, match="'sources' must be an iterable"):
7575
Extension('name', 'file')
7676
with pytest.raises(TypeError):
7777
Extension('name', ['file', 1])

0 commit comments

Comments
 (0)