Skip to content

Commit

Permalink
Issue #279
Browse files Browse the repository at this point in the history
  • Loading branch information
loyada committed Oct 28, 2023
1 parent 589b653 commit 8ae1299
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tests/test_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,8 +584,8 @@ class Person(Structure):
_enable_undefined_value = True

person_model = PersonModel(age=40)
person = Person.from_other_class(person_model, id=123)
assert person == Person(id=123, age=40)
assert Person.from_other_class(person_model, id=123) == Person(id=123, age=40)
assert Person.from_other_class(person_model, id=Undefined) == Person(age=40)


def test_from_trusted_class():
Expand Down
1 change: 1 addition & 0 deletions tests/test_undefined.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def test_undefined():
assert foo == Foo(a=1, b=None)
assert not foo.c
assert foo.to_other_class(dict) == {"a": 1, "b": None, "d": 5}
assert foo.to_other_class(dict, c=Undefined) == {"a": 1, "b": None, "d": 5}
assert foo != Foo(a=1)
assert foo.shallow_clone_with_overrides(a=2) == Foo(a=2, b=None)
assert foo != Foo(a=1, b=None, c=None)
Expand Down
4 changes: 2 additions & 2 deletions typedpy/structures/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,7 @@ class Foo(Structure):

kwargs = {
**{k: v for k, v in args_from_structure.items() if v is not Undefined},
**kw,
**{k: v for k, v in kw.items() if v is not Undefined},
}
return target_class(**kwargs)

Expand Down Expand Up @@ -1527,7 +1527,7 @@ def extract_attr(k):
}
kwargs = {
**{k: v for k, v in args_from_model.items() if v is not Undefined},
**kw,
**{k: v for k, v in kw.items() if v is not Undefined},
}
try:
return cls(**kwargs)
Expand Down

0 comments on commit 8ae1299

Please sign in to comment.