Skip to content

Commit

Permalink
Remove leading underscores from local functions
Browse files Browse the repository at this point in the history
Ref. #282, #302
  • Loading branch information
Alexander Senier authored and treiher committed Jul 23, 2020
1 parent e125063 commit 8f20b45
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions rflx/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,10 +780,10 @@ def relation_error(relation: Relation, left: TypeExpr, right: TypeExpr) -> None:
relation.location,
)

def __resolve_types(
def resolve_types(
left: Expr, right: Expr, literals: Dict[ID, Enumeration],
) -> Tuple[TypeExpr, TypeExpr]:
def __resolve_type(expr: Expr) -> Optional[TypeExpr]:
def resolve_type(expr: Expr) -> Optional[TypeExpr]:
if not isinstance(expr, Variable):
return expr
if expr.identifier in literals:
Expand All @@ -798,14 +798,14 @@ def __resolve_type(expr: Expr) -> Optional[TypeExpr]:
)
return None

lefttype = __resolve_type(left)
righttype = __resolve_type(right)
lefttype = resolve_type(left)
righttype = resolve_type(right)
self.error.propagate()
assert lefttype
assert righttype
return (lefttype, righttype)

def __invalid_relation(left: TypeExpr, right: TypeExpr) -> bool:
def invalid_relation(left: TypeExpr, right: TypeExpr) -> bool:
return (
(isinstance(left, Opaque) and not isinstance(right, (Opaque, Aggregate)))
or (isinstance(left, Array) and not isinstance(right, (Array, Aggregate)))
Expand All @@ -814,7 +814,7 @@ def __invalid_relation(left: TypeExpr, right: TypeExpr) -> bool:

for relation in expression.findall(lambda x: isinstance(x, Relation)):
assert isinstance(relation, Relation)
left, right = __resolve_types(
left, right = resolve_types(
relation.left.simplified(), relation.right.simplified(), literals
)
if isinstance(relation, (Less, LessEqual, Greater, GreaterEqual)):
Expand All @@ -823,9 +823,9 @@ def __invalid_relation(left: TypeExpr, right: TypeExpr) -> bool:
):
relation_error(relation, left, right)
elif isinstance(relation, (Equal, NotEqual)):
if __invalid_relation(left, right):
if invalid_relation(left, right):
relation_error(relation, left, right)
elif __invalid_relation(left=right, right=left):
elif invalid_relation(left=right, right=left):
relation_error(relation, left=right, right=left)
elif isinstance(left, Aggregate) and isinstance(right, Composite):
check_composite_element_range(relation, left, right)
Expand Down

0 comments on commit 8f20b45

Please sign in to comment.