fixhunt

ruff C410

labelled unknown
Runs / 2026-10-17T20-21-05-230Z-6h8d-ruff-C410ruff 0.17.12026-10-17 20:21 UTC8 programs × 2 round(s)16 programs, 9 fired, 0 fixed, 0 findings, 0 rejectedmodel cost $0.0029

Analysis Nemotron 3 Super

Flags redundant list() constructor calls wrapping list or tuple literals.

Fix: Rewrites list(literal) to the literal itself if it's a list literal, or to a list literal with the same elements if it's a tuple literal.

10 hazards
  • If the literal contains a comment inside (e.g., list([1, # comment 2])), the autofix may drop the comment when converting to [1, 2].
  • If the literal is part of a larger expression where the list() call affects operator precedence (e.g., list([1, 2]) + [3]), removing list() could change evaluation order due to binding differences.
  • If the literal is used in a context where the list() call is relied upon to create a new list (e.g., for mutation safety), replacing list((1,2)) with [1,2] still creates a new list, so no semantic change, but if the literal is a variable referencing a mutable list, the fix does not apply—this hazard is not applicable as the rule only triggers on literals.
  • If the code relies on the list() constructor for debugging or side effects (e.g., list(print([1,2]) or [])), the rule does not fire because the argument is not a literal, so no fix is attempted—this hazard is not applicable.
  • If the literal contains nested expressions with side effects (e.g., list([f(), g()])), the rule does not fire because the argument is not a literal (it's a list containing calls), so no fix is attempted—this hazard is not applicable.
  • If the literal is a tuple containing a starred expression (e.g., list((*range(3),))), the rule does not fire because starred expressions are not allowed in tuple literals in this context—invalid syntax, so rule does not fire.
  • If the code is in a string or comment (e.g., '# list([1,2])'), the linter does not parse it as code, so no fix is attempted—this hazard is not applicable.
  • If the literal is a list literal that is empty and the surrounding code depends on the identity of the list (e.g., is(list([])) is not list([])), removing list() changes identity because [] is a singleton in some contexts? Actually, [] is not a singleton; each [] creates a new list, so list([]) and [] are both new lists—no identity difference. However, in CPython, small tuples may be interned, but lists are not. So no hazard.
  • If the literal is a tuple and the code uses the fact that list(tuple) raises TypeError on non-tuple (but the argument is a literal tuple, so safe), no issue.
  • If the literal is a tuple and the rewrite to list literal fails due to being in a context that expects a tuple (e.g., as a key in a dict: {list((1,2)): 3} becomes {[1,2]: 3}), which is invalid because lists are unhashable—this changes behavior from valid to TypeError.

Programs

idresulttitlehazard
r1-p001fired, no fixPrecedence HazardIf the literal is part of a larger expression where the list() call affects operator precedence, removing list() could change evaluation order.
r1-p002fired, no fixType Annotation Runtime Evaluationtype annotations evaluated at runtime, typing-only imports
r1-p003silentStarred Expression Near-MissIf the literal is a tuple containing a starred expression, the rule does not fire because starred expressions are not allowed in tuple literals in this context—invalid syntax, so rule does not fire.
r1-p004silent prediction offWalrus and Comprehension Scopingwalrus, comprehensions scoping, late binding in closures and lambdas
r1-p005fired, no fixCoercion and Roundingint/float/bool coercion, Decimal, division and rounding
r1-p006silent prediction offTuple Type SafetyIf the literal is a tuple and the code uses the fact that list(tuple) raises TypeError on non-tuple (but the argument is a literal tuple, so safe), no issue.
r1-p007fired, no fixComments and Docstringscomments and docstrings attached to the removed or moved code
r1-p008fired, no fixException Handling and Finallyexceptions raised inside the rewritten code, finally/else clauses, exception chaining
r2-p001silent prediction offString formatting interactionstring formatting edge cases: %, format, f-strings, repr vs str, nested quotes
r2-p002fired, no fixMutable default argument aliasingmutable default arguments and aliasing after a rewrite
r2-p003silent prediction offKeyword-only and *args forwardingkeyword-only, positional-only, *args/**kwargs forwarding, defaults evaluated once
r2-p004fired, no fixTuple-to-list-as-dict-key TypeErrorIf the literal is a tuple and the rewrite to list literal fails due to being in a context that expects a tuple (e.g., as a key in a dict: {list((1,2)): 3} becomes {[1,2]: 3}), which is invalid because
r2-p005fired, no fixStar-import and __all__ side effectstar-imports, module-level side effects, __all__
r2-p006silent prediction offShadowed builtin listshadowed builtins and names redefined later in the module
r2-p007silentStarred expression in tuple (no trigger)If the literal is a tuple containing a starred expression (e.g., list((*range(3),))), the rule does not fire because starred expressions are not allowed in tuple literals in this context—invalid synta
r2-p008fired, no fixWalrus and comprehension scopingwalrus, comprehensions scoping, late binding in closures and lambdas

Sources

r1-p001 · Precedence Hazard
1def main():
2 try:
3 result = list([1, 2]) * 2
4 print('Result:', result)
5 except Exception as e:
6 print(type(e).__name__ + ':', str(e))
7if __name__ == '__main__':
8 main()
Result: [1, 2, 1, 2]
r1-p002 · Type Annotation Runtime Evaluation
1from typing import List
2T = list([int])
3def func(x: T[0]) -> None:
4 print('Received:', x)
5func(42)
Received: 42
r1-p003 · Starred Expression Near-Miss
1# This is invalid syntax; commented out to keep program valid.
2# lst = list((*range(3),))
3print('No trigger: starred expression in tuple literal is invalid syntax')
No trigger: starred expression in tuple literal is invalid syntax
r1-p004 · Walrus and Comprehension Scoping
1lst = []
2f = lambda: list((y for y in [lst.append(i) or i for i in range(2)]))
3print('First call:', f())
4print('Second call:', f())
First call: [0, 1]
Second call: [0, 1]
r1-p005 · Coercion and Rounding
1from decimal import Decimal
2vals = list((Decimal('1.5'), Decimal('2.5')))
3total = sum(vals)
4print('Sum:', total)
5print('Rounded:', round(total))
Sum: 4.0
Rounded: 4
r1-p006 · Tuple Type Safety
1def process_tuple(t):
2 return list(t)
3result = process_tuple((1, 2, 3))
4print('List from tuple:', result)
5try:
6 process_tuple('not a tuple')
7except TypeError as e:
8 print('Caught TypeError:', e)
List from tuple: [1, 2, 3]
r1-p007 · Comments and Docstrings
1def get_data():
2 """Returns fixed data."""
3 # This list conversion is redundant
4 return list([10, 20])
5print('Data:', get_data())
Data: [10, 20]
r1-p008 · Exception Handling and Finally
1def risky():
2 try:
3 data = list((1, 2, 0))
4 return 10 / data[2]
5 except ZeroDivisionError as e:
6 raise ValueError('bad divisor') from e
7 else:
8 print('No error')
9 finally:
10 print('Cleanup')
11try:
12 risky()
13except ValueError as e:
14 print('Caught:', e.__cause__.__class__.__name__, '-', e.__cause__)
Cleanup
Caught: ZeroDivisionError - division by zero
r2-p001 · String formatting interaction
1def main():
2 t = ('%s', '%d')
3 s = list(t)
4 print(s[0] % 'hello' + ', ' + s[1] % 42)
5if __name__ == '__main__':
6 main()
hello, 42
r2-p002 · Mutable default argument aliasing
1def f(x=list([1, 2])):
2 x.append(99)
3 return x
4print(f())
5print(f())
[1, 2, 99]
[1, 2, 99, 99]
r2-p003 · Keyword-only and *args forwarding
1def g(*args, sep=':'):
2 lst = list(args)
3 return sep.join(map(str, lst))
4print(g(1, 2, 3))
1:2:3
r2-p004 · Tuple-to-list-as-dict-key TypeError
1try:
2 d = {list((1, 2)): 'ok'}
3 print(d)
4except TypeError as e:
5 print(f'{type(e).__name__}: {e}')
TypeError: cannot use 'list' as a dict key (unhashable type: 'list')
r2-p005 · Star-import and __all__ side effect
1__all__ = [list(['mod_item'])]
2print(__all__[0])
['mod_item']
r2-p006 · Shadowed builtin list
1list = lambda x: x.upper()
2print(list((list,))[0](['a']))
r2-p007 · Starred expression in tuple (no trigger)
1# list((*range(3),)) # SyntaxError: starred expression must be in an iterable unpacking
2print('no trigger')
no trigger
r2-p008 · Walrus and comprehension scoping
1fns = []
2for i in range(3):
3 if (lst := list((i, i+1))) and len(lst) == 2:
4 fns.append(lambda: lst[0])
5print([f() for f in fns])
[2, 2, 2]