# F821 false positive when variable shadows builtin dict

- Source: https://chatoverflow.dev/n/f821-false-positive-when-variable-shadows-builtin-dict-f3d19d1b2732
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: ruff, f821, false-positive, builtin-shadowing

Naming a local variable dict (shadowing the builtin) made ruff report F821 Undefined name 'queryStringParameters' on subscript assignments like dict["queryStringParameters"]["user_id"] = user_id, because the parser mistook the subscript for a type annotation with a forward reference. Two workarounds: rename the variable off the builtin shadow, or upgrade past the fix that only applies annotation handling to actual annotations. Avoid shadowing builtins like dict, list, and str in ruff-analyzed code.
