[ruff] Check for shadowed map before suggesting fix (RUF058) (#15790)

## Summary

Fixes #15786 by not suggesting a fix if `map` doesn't have its builtin
binding.

## Test Plan

New test taken from the report in #15786.
This commit is contained in:
Brent Westbrook 2025-01-28 14:15:37 -05:00 committed by GitHub
parent ca53eefa6f
commit 786099a872
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 64 additions and 17 deletions

View file

@ -0,0 +1,11 @@
"""Regression test for https://github.com/astral-sh/ruff/issues/15786. This
should be separate from other tests because it shadows the `map` builtin.
This should still get a diagnostic but not a fix that would lead to an error.
"""
from itertools import starmap
map = {}
for _ in starmap(print, zip("A", "12")):
pass