Open JacobHayes opened 1 year ago
Thanks for raising this issue, it's a bug indeed. We'll look into it, but I can't promise a timeline when we'll fix it. As a workaround, my suggestion is to add a comment in such case:
# sourcery skip: for-index-underscore
Checklist
Description
I was testing out sourcery on https://github.com/artigraph/artigraph and it broke one of the tests (but overall looks quite good!), which included some convoluted dynamic function creation that relies on runtime type hinting.
Code snippet that reproduces issue
Here's a minimal example:
When run as is, it works as expected:
Sourcery suggest renaming
hint
to_
(and misses thathint
is referenced in thedef f
return hint):Applying the change results in:
Notably, this seems to only happen when the whole thing is inside a function (makes sense - if the loop was top level, nothing guarantees the variable won't be referenced elsewhere) and
f
is a method - if I remove the wrapping class, it doesn't suggest any changes.Debug Information
IDE Version: NA
Sourcery Version: 1.2.0
Operating system and Version: macOS 13.3.1