Skip to content

Commit

Permalink
refactor: guard non-runtime types with TYPE_CHECKING
Browse files Browse the repository at this point in the history
  • Loading branch information
aaraney committed Aug 6, 2024
1 parent 15be92d commit a98164b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 10 deletions.
5 changes: 4 additions & 1 deletion python/ngen_conf/src/ngen/config/path_pair/_utils.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
6 changes: 4 additions & 2 deletions python/ngen_conf/src/ngen/config/path_pair/common.py
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
5 changes: 4 additions & 1 deletion python/ngen_conf/src/ngen/config/path_pair/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
8 changes: 5 additions & 3 deletions python/ngen_init_config/src/ngen/init_config/deserializer.py
Original file line number Diff line number Diff line change
@@ -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 (
Expand All @@ -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):
Expand Down
5 changes: 4 additions & 1 deletion python/ngen_init_config/src/ngen/init_config/serializer.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
7 changes: 5 additions & 2 deletions python/ngen_init_config/src/ngen/init_config/utils.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down

0 comments on commit a98164b

Please sign in to comment.