Skip to content

Commit

Permalink
Simplify iterator usage (#15185)
Browse files Browse the repository at this point in the history
  • Loading branch information
dosisod authored May 4, 2023
1 parent a8bd273 commit fea5c93
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mypy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@ def read_types_packages_to_install(cache_dir: str, after_run: bool) -> list[str]
# No missing stubs.
return []
with open(fnam) as f:
return [line.strip() for line in f.readlines()]
return [line.strip() for line in f]


def install_types(
Expand Down
2 changes: 1 addition & 1 deletion mypy/stubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1667,7 +1667,7 @@ def strip_comments(s: str) -> str:
return s.strip()

with open(allowlist_file) as f:
for line in f.readlines():
for line in f:
entry = strip_comments(line)
if entry:
yield entry
Expand Down
6 changes: 3 additions & 3 deletions mypyc/irbuild/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,10 +812,10 @@ def transform_basic_comparison(
if (
is_int_rprimitive(left.type)
and is_int_rprimitive(right.type)
and op in int_comparison_op_mapping.keys()
and op in int_comparison_op_mapping
):
return builder.compare_tagged(left, right, op, line)
if is_fixed_width_rtype(left.type) and op in int_comparison_op_mapping.keys():
if is_fixed_width_rtype(left.type) and op in int_comparison_op_mapping:
if right.type == left.type:
op_id = ComparisonOp.signed_ops[op]
return builder.builder.comparison_op(left, right, op_id, line)
Expand All @@ -826,7 +826,7 @@ def transform_basic_comparison(
)
elif (
is_fixed_width_rtype(right.type)
and op in int_comparison_op_mapping.keys()
and op in int_comparison_op_mapping
and isinstance(left, Integer)
):
op_id = ComparisonOp.signed_ops[op]
Expand Down

0 comments on commit fea5c93

Please sign in to comment.