Skip to content

Commit 21a28f4

Browse files
committed
Enable FURB187 - avoid reverse list copy
1 parent d8bf6e2 commit 21a28f4

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

mypy/semanal_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def process_top_levels(graph: Graph, scc: list[str], patches: Patches) -> None:
179179

180180
# Reverse order of the scc so the first modules in the original list will be
181181
# be processed first. This helps with performance.
182-
scc = list(reversed(scc))
182+
scc = list(reversed(scc)) # noqa: FURB187
183183

184184
# Initialize ASTs and symbol tables.
185185
for id in scc:

mypyc/analysis/dataflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ def run_analysis(
542542
# Set up initial state for worklist algorithm.
543543
worklist = list(blocks)
544544
if not backward:
545-
worklist = worklist[::-1] # Reverse for a small performance improvement
545+
worklist.reverse() # Reverse for a small performance improvement
546546
workset = set(worklist)
547547
before: dict[BasicBlock, set[T]] = {}
548548
after: dict[BasicBlock, set[T]] = {}

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ select = [
146146
"C4", # flake8-comprehensions
147147
"SIM101", # merge duplicate isinstance calls
148148
"SIM201", "SIM202", "SIM222", "SIM223", # flake8-simplify
149+
"FURB187", # avoid list reverse copy
149150
"FURB188", # use str.remove(pre|suf)fix
150151
"ISC001", # implicitly concatenated string
151152
"RET501", "RET502", # better return None handling

0 commit comments

Comments
 (0)