From 2278547f8b38ba74ceb73c19f0f660d98ea52c1a Mon Sep 17 00:00:00 2001 From: Austin Raney Date: Tue, 10 Sep 2024 15:11:44 -0400 Subject: [PATCH] fix: explicitly call __init__ to setup PurePath instance (fixes #193) --- python/ngen_conf/src/ngen/config/path_pair/path_pair.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/python/ngen_conf/src/ngen/config/path_pair/path_pair.py b/python/ngen_conf/src/ngen/config/path_pair/path_pair.py index f829676e..c3f5b84f 100644 --- a/python/ngen_conf/src/ngen/config/path_pair/path_pair.py +++ b/python/ngen_conf/src/ngen/config/path_pair/path_pair.py @@ -1,6 +1,7 @@ from __future__ import annotations import os +import sys from pathlib import Path, PosixPath, WindowsPath from .protocol import Reader, Writer, Serializer, Deserializer @@ -84,6 +85,9 @@ def __new__( # type: ignore inner = _MaybeInner[cls._parameters[0]](inner=inner).inner # type: ignore cls = WindowsPathPair[T] if os.name == "nt" else PosixPathPair[T] self: WindowsPathPair[T] | PosixPathPair[T] = Path.__new__(cls, *args, **kwargs) + # explicitly call __init__ to setup instance (see #193) + if sys.version_info >= (3, 12): + self.__init__(*args) self._inner = inner # type: ignore self._serializer = serializer # type: ignore self._deserializer = deserializer # type: ignore @@ -316,6 +320,9 @@ def __new__( # type: ignore deserializer=deserializer, **kwargs, ) + # explicitly call __init__ to setup instance (see #193) + if sys.version_info >= (3, 12): + self.__init__(*args) self._inner = inner self._serializer = serializer self._deserializer = deserializer