fixhunt

ruff RUF028

labelled unknown
Runs / 2026-10-17T21-43-24-102Z-49lj-ruff-RUF028ruff 0.17.12026-10-17 21:43 UTC8 programs × 2 round(s)16 programs, 2 fired, 0 fixed, 0 findings, 1 rejectedmodel cost $0.0058

Analysis Nemotron 3 Super

Flags formatter suppression comments (`fmt:` or `yapf:`) placed where they have no effect on formatting.

Fix: Removes the ineffective formatter suppression comment line entirely, leaving surrounding code and other comments unchanged.

10 hazards
  • Removing a `# fmt: off` comment may allow the formatter to reformat subsequent code, changing its layout but not its semantics.
  • Removing a `# fmt: on` comment may cause the formatter to continue suppressing formatting beyond the intended region, altering code style inconsistently.
  • Removing a `# fmt: skip` comment may cause the formatter to reformat the immediately following line, potentially changing its appearance.
  • Removing a `# yapf: disable` comment may allow YAPF (if used) to format code that was previously excluded, affecting formatting only.
  • Removing a `# yapf: enable` comment may cause YAPF to remain disabled for subsequent code, leading to inconsistent formatting if YAPF is active elsewhere.
  • If the suppression comment is the only content on a line, its removal may delete a blank line that was intentionally used for visual separation, affecting readability.
  • If the suppression comment shares a line with other code (e.g., after a statement), the fix does not apply because the rule only triggers on full-line comments—this hazard does not occur under correct rule application.
  • In rare cases, removing a comment could affect tools that parse comments for metadata (e.g., docstring extractors, linters), though standard Python execution ignores comments.
  • The fix does not alter AST structure or runtime behavior, as comments are stripped during parsing and have no semantic meaning.
  • If the comment is part of a multi-line string or tokenized incorrectly due to encoding issues, removal might alter tokenization—but this is irrelevant as the rule only targets syntactically valid comment lines.

Programs

idresulttitlehazard
r1-p001fired, no fix# fmt: skip before expression affecting list literalRemoving a `# fmt: skip` comment may cause the formatter to reformat the immediately following line, potentially changing its appearance.
r1-p002silent prediction offshadowed builtin sum after fmt: off blockshadowed builtins and names redefined later in the module
r1-p003silentencoding declaration with fmt: off aboveIf the comment is part of a multi-line string or tokenized incorrectly due to encoding issues, removal might alter tokenization—but this is irrelevant as the rule only targets syntactically valid comm
r1-p004silent prediction offbytes vs str after fmt: onbytes vs str, encoding and newline handling, text vs binary modes
r1-p005invalidfloat division after fmt: skipint/float/bool coercion, Decimal, division and rounding
r1-p006silent prediction offcomment-dependent tool simulationIn rare cases, removing a comment could affect tools that parse comments for metadata (e.g., docstring extractors, linters), though standard Python execution ignores comments.
r1-p007silent prediction offf-string with escaped quotes after fmt: onstring formatting edge cases: %, format, f-strings, repr vs str, nested quotes
r1-p008silent prediction offyapf: enable removal leaves yapf disabledRemoving a `# yapf: enable` comment may cause YAPF to remain disabled for subsequent code, leading to inconsistent formatting if YAPF is active elsewhere.
r2-p001silent prediction offCustom writer without close methodcontext managers that are not files, objects with write() but no close()
r2-p002fired, no fixFormatter skip affecting line alignmentRemoving a `# fmt: skip` comment may cause the formatter to reformat the immediately following line, potentially changing its appearance.
r2-p003silent prediction offParameter kinds with defaults evaluated oncekeyword-only, positional-only, *args/**kwargs forwarding, defaults evaluated once
r2-p004silent prediction offRuntime type annotation evaluationtype annotations evaluated at runtime, typing-only imports
r2-p005silent prediction offString formatting edge casesstring formatting edge cases: %, format, f-strings, repr vs str, nested quotes
r2-p006silent prediction offEvaluation order with side effectsevaluation order and side effects when expressions are merged, duplicated or deleted
r2-p007silent prediction offWalrus and comprehension scopingwalrus, comprehensions scoping, late binding in closures and lambdas
r2-p008silent prediction offFile write with non-str data and truncationfile modes and truncation, partial writes, non-str data passed to write

Sources

r1-p001 · # fmt: skip before expression affecting list literal
1data = []
2# fmt: skip
3data += [1,
4 2, 3]
5print(data)
[1, 2, 3]
r1-p002 · shadowed builtin sum after fmt: off block
1sum = 0
2# fmt: off
3sum = lambda x: x + 1
4# fmt: on
5print(sum([1, 2]))
r1-p003 · encoding declaration with fmt: off above
1# -*- coding: utf-8 -*-
2# fmt: off
3print('café')
4# fmt: on
café
r1-p004 · bytes vs str after fmt: on
1# fmt: off
2data = b'hello'
3# fmt: on
4try:
5 print(data.upper())
6except AttributeError as e:
7 print(type(e).__name__, str(e))
b'HELLO'
r1-p005 · float division after fmt: skip (generated program does not parse: Traceback (most recent call last):)
1# fmt: skip
2x = 1 /
3 3
4print(x)
5print(type(x))
r1-p006 · comment-dependent tool simulation
1metadata = []
2# fmt: off
3# tool: keep-me
4x = 1
5# fmt: on
6if '# tool: keep-me' in open(__file__).read():
7 metadata.append('found')
8print(len(metadata))
1
r1-p007 · f-string with escaped quotes after fmt: on
1name = 'alice'
2# fmt: off
3msg = f"He said, \"{name}\""
4# fmt: on
5print(msg)
He said, "alice"
r1-p008 · yapf: enable removal leaves yapf disabled
1# yapf: disable
2x = 1
3# yapf: enable
4y = 2
5print(x, y)
1 2
r2-p001 · Custom writer without close method
1# fmt: off
2class Writer:
3 def __init__(self):
4 self.data = ''
5 def write(self, s):
6 self.data += s
7w = Writer()
8with w:
9 w.write('hello')
10print(w.data)
r2-p002 · Formatter skip affecting line alignment
1x = 1
2# fmt: skip
3y = 2
4z = x + y
5print(z)
3
r2-p003 · Parameter kinds with defaults evaluated once
1# fmt: off
2def f(a, /, b, *, c=[]):
3 c.append(1)
4 return a, b, c
5print(f(1, 2))
6print(f(1, 2))
(1, 2, [1])
(1, 2, [1, 1])
r2-p004 · Runtime type annotation evaluation
1# fmt: off
2T = int
3AnnotatedType = list
4x: AnnotatedType = []
5x.append(1)
6print(x)
[1]
r2-p005 · String formatting edge cases
1# fmt: off
2name = 'Alice\"Bob'
3greeting = f"Hello {name}"
4print(greeting)
Hello Alice"Bob
r2-p006 · Evaluation order with side effects
1# fmt: off
2i = 0
3def next_i():
4 nonlocal i
5 i += 1
6 return i
7a = [next_i(), next_i()]
8print(a)
r2-p007 · Walrus and comprehension scoping
1# fmt: off
2funcs = []
3for i in range(3):
4 if (x := i) == 0:
5 pass
6 funcs.append(lambda: x)
7print([f() for f in funcs])
[2, 2, 2]
r2-p008 · File write with non-str data and truncation
1# fmt: off
2with open('test.txt', 'wb') as f:
3 f.write(b'hello')
4 f.write(b'world')
5with open('test.txt', 'rb') as f:
6 print(f.read())
7import os
8os.remove('test.txt')
b'helloworld'