# ruff UP018: fix changes program behavior

Internal evidence sheet generated by fixhunt. Not an issue text. A human re-verifies, checks the duplicates
below, and writes the upstream report in their own words following the project's AI policy.

- Tool: ruff ruff 0.17.1
- Rule: UP018 (tool labels the fix: unknown, this fix reported as safe)
- Oracle: fix-changes-behavior
- Judge (Nemotron 3 Ultra, advisory): real, severity medium. The rule rewrites the string literal 'int(5)' inside a type annotation to '5', changing the annotation's stored value from 'int(5)' to '5'. Since annotations are accessible at runtime via __annotations__, this alters program behavior for code that inspects annotations, which is a plausible use case.
- Program: minimized from 4 to 3 lines

## Reproducer

```python
def f(x: 'int(5)'):
    return x
print(f.__annotations__['x'])
```

## Commands

```sh
python3 prog.py
ruff check --preview --isolated --select UP018 --fix prog.py
python3 prog.py
```

## Observed

```
stdout before:
int(5)
stdout after:
5
```

## Diff applied by the fix

```diff
--- orig.py	2026-10-22 13:39:08.153773875 -0400
+++ fixed.py	2026-10-22 13:39:10.664816384 -0400
@@ -1,3 +1,3 @@
-def f(x: 'int(5)'):
+def f(x: '5'):
     return x
 print(f.__annotations__['x'])
```

## Why the rewrite is not equivalent (model draft, verify before use)

The annotation string `'int(5)'` was changed to `'5'`, altering its literal value; accessing `f.__annotations__['x']` returns this string directly, so the output changes from `int(5)` to `5`. This modification affects runtime behavior because annotations are preserved as strings and inspected explicitly. Changing their content violates semantic equivalence even if the type meaning seems similar, as the program depends on the exact annotation text. Thus the fix is not semantics‑preserving despite being labeled safe.

## Upstream search

Queries: "UP018 fix", "UP018 annotation string literal", "ruff UP018 forward reference simplification", "annotation quote removal numeric literal"

- no duplicate or related report found among 0 hits

