Closed drdavella closed 7 months ago
This is happening because the default behavior of libcst's add import visitor will always try to the add the import at the top of the file if it is not there, regardless if the import appears in any other line.
So this will always be an issue. However, I think I can mitigate this issue for this particular case.
In this example, the
harden-pyyaml
codemod addsimport yaml
even though it already exists. I'm not sure whether this is a bug with LibCST, with this codemod specifically, or with Codemodder more generally, so it bears some additional investigation:https://github.com/unitedstates/congress-legislators/pull/922/files