diff --git a/python/ngen_conf/src/ngen/config/path_pair/_utils.py b/python/ngen_conf/src/ngen/config/path_pair/_utils.py index d33e7077..3edaa6e5 100644 --- a/python/ngen_conf/src/ngen/config/path_pair/_utils.py +++ b/python/ngen_conf/src/ngen/config/path_pair/_utils.py @@ -1,7 +1,10 @@ from __future__ import annotations import sys -from pathlib import Path +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from pathlib import Path def path_unlink_37(p: Path, missing_ok: bool): diff --git a/python/ngen_conf/src/ngen/config/path_pair/common.py b/python/ngen_conf/src/ngen/config/path_pair/common.py index 6aa79a92..c505c39c 100644 --- a/python/ngen_conf/src/ngen/config/path_pair/common.py +++ b/python/ngen_conf/src/ngen/config/path_pair/common.py @@ -1,11 +1,13 @@ from __future__ import annotations from pydantic import BaseModel -from pathlib import Path from .protocol import Deserializer -from typing import TypeVar +from typing import TypeVar, TYPE_CHECKING + +if TYPE_CHECKING: + from pathlib import Path M = TypeVar("M", bound=BaseModel) diff --git a/python/ngen_conf/src/ngen/config/path_pair/protocol.py b/python/ngen_conf/src/ngen/config/path_pair/protocol.py index 69c7c32d..1e8d6ebe 100644 --- a/python/ngen_conf/src/ngen/config/path_pair/protocol.py +++ b/python/ngen_conf/src/ngen/config/path_pair/protocol.py @@ -7,9 +7,12 @@ else: from typing_extensions import Protocol -from pathlib import Path from .typing import T, S +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from pathlib import Path class Writer(Protocol): diff --git a/python/ngen_init_config/src/ngen/init_config/deserializer.py b/python/ngen_init_config/src/ngen/init_config/deserializer.py index b40b2bcd..850c055d 100644 --- a/python/ngen_init_config/src/ngen/init_config/deserializer.py +++ b/python/ngen_init_config/src/ngen/init_config/deserializer.py @@ -1,7 +1,5 @@ from __future__ import annotations -from pathlib import Path - from .core import Base from .utils import merge_class_attr from ._deserializers import ( @@ -12,7 +10,11 @@ from_toml_str, ) -from typing_extensions import Self +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from typing_extensions import Self + from pathlib import Path class IniDeserializer(Base): diff --git a/python/ngen_init_config/src/ngen/init_config/serializer.py b/python/ngen_init_config/src/ngen/init_config/serializer.py index 5263e198..9b231668 100644 --- a/python/ngen_init_config/src/ngen/init_config/serializer.py +++ b/python/ngen_init_config/src/ngen/init_config/serializer.py @@ -1,9 +1,12 @@ from __future__ import annotations import os -import pathlib from . import core, format_serializers, utils +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + import pathlib class IniSerializer(core.Base): diff --git a/python/ngen_init_config/src/ngen/init_config/utils.py b/python/ngen_init_config/src/ngen/init_config/utils.py index 0b1b6447..16da3e86 100644 --- a/python/ngen_init_config/src/ngen/init_config/utils.py +++ b/python/ngen_init_config/src/ngen/init_config/utils.py @@ -1,10 +1,13 @@ from __future__ import annotations import importlib -from typing import Any -from types import ModuleType +from typing import TYPE_CHECKING from copy import deepcopy +if TYPE_CHECKING: + from typing import Any + from types import ModuleType + __SENTINEL = object() __MERGE_SENTINEL = object()