Skip to content

Commit

Permalink
chore[config.py]: Remove impossible case
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Vasenin committed Sep 23, 2020
1 parent 010ec74 commit c261bda
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ build
dist
.DS_Store
tests/data/good2.py
.coverage
2 changes: 1 addition & 1 deletion ntc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .config import *
from .errors import *

__version__ = "0.1.8"
__version__ = "0.1.9"
8 changes: 2 additions & 6 deletions ntc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,17 +259,13 @@ def _set_new(self, key: str, value: Any) -> None:

def _set_existing(self, key: str, value: Any) -> None:
cur_attr = super().__getitem__(key)
value_type = type(value)
type(value)
if isinstance(cur_attr, CfgNode):
raise NodeReassignment(f"Nested CfgNode {key} cannot be reassigned.")
elif isinstance(cur_attr, CfgLeaf):
cur_attr.value = value
else:
if not isinstance(cur_attr, value_type):
raise TypeMismatch(
f"Current value of attribute {key} is of type {type(cur_attr)}, but new one is of {value_type}."
)
super().__setitem__(key, value)
raise AssertionError("This should not happen!")

def _init_with_base(self, base: dict) -> None:
if isinstance(base, CfgNode):
Expand Down

0 comments on commit c261bda

Please sign in to comment.