• sturger@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    12
    ·
    2 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.

    • trolololol@lemmy.world
      link
      fedilink
      arrow-up
      18
      ·
      2 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.

    • barsoap@lemm.ee
      link
      fedilink
      arrow-up
      23
      ·
      2 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.

    • derpgon@programming.dev
      link
      fedilink
      arrow-up
      10
      ·
      2 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.

      • sturger@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        4
        ·
        2 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
      arrow-up
      11
      ·
      2 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);@lemmy.ca
        link
        fedilink
        arrow-up
        4
        arrow-down
        1
        ·
        2 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.

    • killabeezio@lemm.ee
      link
      fedilink
      arrow-up
      6
      ·
      2 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

    • LeroyJenkins@lemmy.world
      link
      fedilink
      arrow-up
      3
      ·
      2 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.

    • pinball_wizard@lemmy.zip
      link
      fedilink
      arrow-up
      4
      arrow-down
      2
      ·
      2 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.