Skip to content

Commit

Permalink
chore(node): cast module to proper type
Browse files Browse the repository at this point in the history
  • Loading branch information
Rizhiy committed Jun 11, 2024
1 parent 289a72e commit a6361e9
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pycs/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from copy import copy
from itertools import chain
from pathlib import Path, PosixPath
from typing import TYPE_CHECKING, Any, Callable, Iterable, Mapping, MutableMapping
from types import ModuleType
from typing import Any, Callable, Iterable, Mapping, MutableMapping, cast

import yaml

Expand All @@ -29,9 +30,6 @@

from .leaf import CfgLeaf

if TYPE_CHECKING:
from types import ModuleType

LOGGER = logging.getLogger(__name__)


Expand Down Expand Up @@ -494,7 +492,7 @@ def _update_module(self, key: str, value) -> None:
lines = [reference_comment]
valid_types = [bool, int, float, str]
if isinstance(value, type):
module: ModuleType = inspect.getmodule(value) # type: ignore
module = cast(ModuleType, inspect.getmodule(value))
lines.append(f"from {module.__name__} import {value.__name__}\n")
lines.append(f"{key} = {value.__name__}\n")
elif type(value) in valid_types:
Expand Down

0 comments on commit a6361e9

Please sign in to comment.