Skip to content

Enable FURB187 - avoid reverse list copy #18716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypy/semanal_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def process_top_levels(graph: Graph, scc: list[str], patches: Patches) -> None:

# Reverse order of the scc so the first modules in the original list will be
# be processed first. This helps with performance.
scc = list(reversed(scc))
scc = list(reversed(scc)) # noqa: FURB187 intentional copy

# Initialize ASTs and symbol tables.
for id in scc:
Expand Down
2 changes: 1 addition & 1 deletion mypyc/analysis/dataflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ def run_analysis(
# Set up initial state for worklist algorithm.
worklist = list(blocks)
if not backward:
worklist = worklist[::-1] # Reverse for a small performance improvement
worklist.reverse() # Reverse for a small performance improvement
workset = set(worklist)
before: dict[BasicBlock, set[T]] = {}
after: dict[BasicBlock, set[T]] = {}
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ select = [
"SIM201", "SIM202", "SIM222", "SIM223", # flake8-simplify
"FURB168", # Prefer is operator over isinstance for None checks
"FURB169", # Do not use is comparison with type(None). Use None
"FURB187", # avoid list reverse copy
"FURB188", # use str.remove(pre|suf)fix
"ISC001", # implicitly concatenated string
"RET501", "RET502", # better return None handling
Expand Down