• sturger
    link
    fedilink
    English
    1221 days ago

    Honest question: I haven’t used AI much. Are there any AIs or IDEs that can reliably rename a variable across all instances in a medium sized Python project? I don’t mean easy stuff that an editor can do (e.g. rename QQQ in all instances and get lucky that there are no conflicts). I mean be able to differentiate between local and/or library variables so it doesn’t change them, only the correct versions.

    • @barsoap@lemm.ee
      link
      fedilink
      2321 days ago

      Not reliably, no. Python is too dynamic to do that kind of thing without solving general program equivalence which is undecidable.

      Use a static language, problem solved.

    • @trolololol@lemmy.world
      link
      fedilink
      1821 days ago

      I’m going to laugh in Java, where this has always been possible and reliable. Not like ai reliable, but expert reliable. Because of static types.

    • bitwolf
      link
      fedilink
      English
      1321 days ago

      For the most part “Rename symbol” in VSCode will work well. But it’s limited by scope.

      • sturger
        link
        fedilink
        English
        421 days ago

        Yeah, I’m looking for something that would understand the operation (? insert correct term here) of the language well enough to rename intelligently.

    • @lapping6596@lemmy.world
      link
      fedilink
      1121 days ago

      I use pycharm for this and in general it does a great job. At work we’ve got some massive repos and it’ll handle it fine.

      The “find” tab shows where it’ll make changes and you can click “don’t change anything in this directory”

      • setVeryLoud(true);
        link
        fedilink
        421 days ago

        Yes, all of JetBrains’ tools handle project-wide renames practically perfectly, even in weirder things like Angular projects where templates may reference variables.

    • @derpgon@programming.dev
      link
      fedilink
      1021 days ago

      IntelliJ IDEA, if it knows it is the same variable, it will rename it. Usually works in a non fucked up codebase that uses eval or some obscure constructs like saving a variable name into a variable as a string and dynamically invoking it.

    • @killabeezio@lemm.ee
      link
      fedilink
      621 days ago

      Itellij is actually pretty good at this. Besides that, cursor or windsurf should be able to. I was using cursor for a while and when I needed to reactor something, it was pretty good at picking that up. It kept crashing on me though, so I am now trying windsurf and some other options. I am missing the auto complete features in cursor though as I would use this all the time to fill out boilerplate stuff as I write.

      The one key difference in cursor and windsurf when compared to other products is that it will look at the entire context again for any changes or at least a little bit of it. You make a change, it looks if it needs to make changes elsewhere.

      I still don’t trust AI to do much though, but it’s an excellent helper

    • @pinball_wizard@lemmy.zip
      link
      fedilink
      421 days ago

      Okay, I realize I’m that person, but for those interested:

      tree, cat and sed get the job done nicely.

      And… it’s my nap time, now. Please keep the Internet working, while I’m napping. I have grown fond of parts of it. Goodnight.

    • @LeroyJenkins@lemmy.world
      link
      fedilink
      321 days ago

      most IDEs are pretty decent at it if you configure them correctly. I used intelliJ and it knows the difference. use the refactor feature and it’ll crawl references, not just rename all instances.