# ruff E714: 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: E714 (tool labels the fix: unknown, this fix reported as safe)
- Oracle: fix-changes-behavior
- Judge (Nemotron 3 Ultra, advisory): introspection-only, severity low. The rewrite changes `not b is b'hello'` to `b is not b'hello'`, which is semantically equivalent. The only observed difference is the SyntaxWarning message text, which quotes the source code and therefore changes to reflect the rewritten form (`"is not" with 'bytes' literal` instead of `"is" with 'bytes' literal`). This is pure source-text introspection, not a runtime behavior change.
- Program: minimized from 5 to 2 lines

## Reproducer

```python
b = b'hello'
print('Bytes check:', not b is b'hello')
```

## Commands

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

## Observed

```
stderr before: <wd>/prog: SyntaxWarning: "is" with 'bytes' literal. Did you mean "=="?
stderr after: <wd>/prog: SyntaxWarning: "is not" with 'bytes' literal. Did you mean "!="?
```

## Diff applied by the fix

```diff
--- orig.py	2026-10-22 13:31:38.845195743 -0400
+++ fixed.py	2026-10-22 13:31:38.946197438 -0400
@@ -1,2 +1,2 @@
 b = b'hello'
-print('Bytes check:', not b is b'hello')
+print('Bytes check:', b is not b'hello')
```

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

The original expression `not b is b'hello'` evaluates as `(not b) is b'hello'`, where `not b` yields False (since non-empty bytes are truthy), so it checks whether False is identical to the byte literal—always false. The rewritten form `b is not b'hello'` correctly groups as `b is (not b'hello')`, testing identity between `b` and the negated literal; since `not b'hello'` is also False, this similarly compares `b` to False via identity—but now directly on `b`. Though both yield false here due to interning quirks, the operator precedence change alters evaluation order and meaning generally, making the transformation unsafe for arbitrary values. The warning shift reflects this semantic difference in how Python parses chained identity operations.

## Upstream search

Queries: "E714 fix", "E714 bytes identity comparison", "not x is y pattern", "SyntaxWarning bytes literal"

- related: https://github.com/astral-sh/ruff/issues/4082
  E714 complex logic handling with chained 'is' comparisons, same rule but different construct (chained vs negated)
- related: https://github.com/astral-sh/ruff/issues/1237
  E711 autofix messes up quotes, same autofix quality problem but different rule (E711 vs E714)

<details><summary>All hits</summary>

- [github, open] Implement remaining `pycodestyle` rules — https://github.com/astral-sh/ruff/issues/2402
- [github, closed] 0.16.0 removed 18 rules from the default set without recording it in BREAKING_CHANGES.md — https://github.com/astral-sh/ruff/issues/27199
- [github, closed] Please remove all rules without an automated fix from default rules — https://github.com/astral-sh/ruff/issues/27177
- [github, closed] Isort rule misses unsorted imports when using user-level ruff.toml file on windows — https://github.com/astral-sh/ruff/issues/19646
- [github, closed] [QA] Should Ruff be able to fix indentation errors (E999) ? — https://github.com/astral-sh/ruff/issues/11846
- [github, closed] Pack of fuzzer Autofix/Infinite loop errors [2] — https://github.com/astral-sh/ruff/issues/8402
- [github, closed] Pack of fuzzer Autofix/Infinite loop errors — https://github.com/astral-sh/ruff/issues/7455
- [github, closed] Fixed code unformatted — https://github.com/astral-sh/ruff/issues/8619
- [github, closed] E714 Complex logic handling — https://github.com/astral-sh/ruff/issues/4082
- [github, closed] Add option to disable preview warnings — https://github.com/astral-sh/ruff/issues/8620
- [tavily] Multi-root workspace makes Ruff use wrong settings · Issue #925 · astral-sh/ruff-vscode · GitHub — https://github.com/astral-sh/ruff-vscode/issues/925
- [tavily] Use str.casefold() instead of str.lower() for comparison. · Issue #7728 · astral-sh/ruff · GitHub — https://github.com/astral-sh/ruff/issues/7728
- [tavily] [`pylint`] Implement `invalid-bytes-returned` (`E0308`) by tibor-reiss · Pull Request #10959 · astral-sh/ruff · GitHub — https://github.com/astral-sh/ruff/pull/10959
- [github, open] formatter ignores `fmt: off` pragma inside match expression — https://github.com/astral-sh/ruff/issues/28340
- [github, open] Add an opt-in rule to prefer `from x import y` over `import x` — https://github.com/astral-sh/ruff/issues/25303
- [github, open] Proposal: Disallow Instance Variable Shadowing of Class Variable Annotations — https://github.com/astral-sh/ruff/issues/18513
- [github, open] PLR1716 (boolean-chained-comparison) does not detect attribute access expressions — https://github.com/astral-sh/ruff/issues/25041
- [github, open] Rules for pandas 3.0 migration (chained assignment, object-dtype string checks)? — https://github.com/astral-sh/ruff/issues/29212
- [github, open] Rule suggestion: no negated condition in if-else — https://github.com/astral-sh/ruff/issues/24249
- [github, open] Support for refurb — https://github.com/astral-sh/ruff/issues/1348
- [github, open] New rule suggestion: flag identical stacked decorators — https://github.com/astral-sh/ruff/issues/26042
- [github, open] Consider using `Diagnostic`s for semantic syntax errors — https://github.com/astral-sh/ruff/issues/20901
- [github, open] Rules/Request:  Airflow DAGs checks — https://github.com/astral-sh/ruff/issues/4421
- [tavily] Warn about error being related to a deprecated rule · Issue #18349 · astral-sh/ruff · GitHub — https://github.com/astral-sh/ruff/issues/18349
- [tavily] [syntax-errors] Remaining syntax errors raised by the compiler · Issue #17412 · astral-sh/ruff · GitHub — https://github.com/astral-sh/ruff/issues/17412
- [tavily] ANN401 doesn't work in overloads · Issue #5803 · astral-sh/ruff · GitHub — https://github.com/astral-sh/ruff/issues/5803
- [github, closed] E711: `--fix` doesn't always fix and messes up quotes — https://github.com/astral-sh/ruff/issues/1237

</details>
