-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
previewRelated to preview mode featuresRelated to preview mode featuresruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
Summary
The fix for dict-iter-missing-items (PLE1141) is suppressed when the relevant dict’s keys are all 2-tuples in its initial binding. This usually makes sense, but it doesn’t make sense when the dict is defined as empty. In that case, there is no reason to assume that any keys added later will be 2-tuples, and that is a rare pattern so they probably won’t be, so PLE1141 should allow the fix. If the empty dict is annotated to have 2-tuple keys, as in dict[tuple[int, str], bool], though, it is still appropriate to suppress the fix. Example:
$ cat >ple1141.py <<'# EOF'
data = {}
data["x"] = 1
for k, v in data:
print(f"{k=} {v=}")
# EOF
$ ruff --isolated check ple1141.py --select PLE1141 --preview
All checks passed!Version
ruff 0.14.3 (8737a2d 2025-10-30)
Metadata
Metadata
Assignees
Labels
previewRelated to preview mode featuresRelated to preview mode featuresruleImplementing or modifying a lint ruleImplementing or modifying a lint rule