Skip to content

Commit 1a05ceb

Browse files
Update exprlength.py
1 parent e2b6af2 commit 1a05ceb

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

mypy/exprlength.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ def get_static_expr_length(expr: Expression, context: Optional[Block] = None) ->
5151

5252
# List, tuple literals (with possible star expressions)
5353
if isinstance(expr, (ListExpr, TupleExpr)):
54-
# if there are no star expressions, or we know the length of them,
55-
# we know the length of the expression
5654
stars = [get_static_expr_length(i, context) for i in expr.items if isinstance(i, StarExpr)]
57-
other = sum(not isinstance(i, StarExpr) for i in expr.items)
58-
return other + sum(star for star in stars if star is not None)
55+
if None not in stars:
56+
# if there are no star expressions, or we know the
57+
# length of them, we know the length of the expression
58+
other = sum(not isinstance(i, StarExpr) for i in expr.items)
59+
return other + sum(star for star in stars if star is not None)
5960
elif isinstance(expr, SetExpr):
6061
# TODO: set expressions are more complicated, you need to know the
6162
# actual value of each item in order to confidently state its length

0 commit comments

Comments
 (0)