• sturger@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    8
    ·
    11 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
      ·
      11 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
      16
      ·
      11 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
      ·
      11 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
        3
        ·
        11 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
      7
      ·
      11 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
        ·
        11 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.

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