Skip to content

Commit

Permalink
Bring Variable and VariableSet back to 100% coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ashuping committed Oct 18, 2024
1 parent 5f07d0a commit 81414a9
Show file tree
Hide file tree
Showing 3 changed files with 394 additions and 177 deletions.
18 changes: 9 additions & 9 deletions exseos/types/Variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,8 @@ def __init__(self, v1: Variable, v2: Variable, note: str = ""):

msg = (
f"{type(v1).__name__} {v1.name} has {v1_type}, "
+ f"but {type(v2).__name} {v2.name} has {v2_type}!"
+ f" {note}"
if note
else ""
+ f"but {type(v2).__name__} {v2.name} has {v2_type}!"
+ (f" {note}" if note else "")
)

super().__init__(msg)
Expand Down Expand Up @@ -436,10 +434,8 @@ def __init__(self, v1: Variable, v2: Variable, note: str = ""):

msg = (
f"{type(v1).__name__} {v1.name} has {v1_type}, "
+ f"but {type(v2).__name} {v2.name} has {v2_type}!"
+ f" {note}"
if note
else ""
+ f"but {type(v2).__name__} {v2.name} has {v2_type}!"
+ (f" {note}" if note else "")
)

super().__init__(msg)
Expand Down Expand Up @@ -693,7 +689,11 @@ def assert_types_match(
if v1.var_type == Nothing() or v2.var_type == Nothing():
return Okay(None)

if issubclass(v2.var_type.val, v1.var_type.val):
if issubclass(v2.var_type.val, v1.var_type.val) and not (
# Special case: bools are apparently a subclass of int in python.
# We don't want that behavior here.
v2.var_type.val is bool and v1.var_type.val is int
):
return Okay(None)

if v1.var_type_inferred or v2.var_type_inferred:
Expand Down
Loading

0 comments on commit 81414a9

Please sign in to comment.