Community
    • Login

    Python Indent plugin not working correctly?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    23 Posts 8 Posters 7.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Steven HaymesS
      Steven Haymes @Michael Vincent
      last edited by Steven Haymes

      @Michael-Vincent

      I got it on the batch file doing the heavy lifting. Your suggestion for a NppExec script to run yapf:

      cmd /c yapf -i “$(FULL_CURRENT_PATH)”

      is similar to my my NppExec scripts to run Pylint and Flake8:

      C:\Python37\Scripts\pylint.exe “$(FULL_CURRENT_PATH)”
      C:\Python37\Scripts\flake8.exe “$(FULL_CURRENT_PATH)”

      Pylint and Flake8 only read my current Python file in NPP. They does not modify it. Does your NppExec example script that runs yapf actually modify the current Python file in NPP?

      Thanks,

      Steve

      1 Reply Last reply Reply Quote 1
      • Michael VincentM
        Michael Vincent
        last edited by

        Yes, that’s what the “-i” argument to yapf (in-place) and subsequent NPP_OPEN - to reopen the file and force a N++ refresh do.

        PS VinsWorldcom@C:\Users\VinsWorldcom> yapf -h  | grep "in-place"
          -i, --in-place        make changes to files in place
        
        1 Reply Last reply Reply Quote 2
        • Derek BrownD
          Derek Brown
          last edited by

          Hey, this is old but I just now stumbled upon it. I am the author of this plugin.

          As some of the posters above have figured out, the plugin does not attempt to follow PEP8. This is not because I have anything against PEP8, but simply I didn’t want to deal with that amount of parsing. I originally wrote this plugin to deal with the simple annoyance of having to tab every time I opened a new block. It applies a very simple heuristic of checking the start of the line for one of the keywords that open a new block in Python.

          It can actually be tricked into doing the wrong thing in a number of other situations (fairly unlikely situations though), such as having a multi-line statement to open a block, or using one of those keywords at the start of a line in a multi-line string. These situations are sufficiently rare that I have never attempted to fix them. In the much more common case of line continuations (which OP is talking about), I simply manually align them with space.

          If you want to get in touch with me about the plugin the best way is to open an issue on the Bitbucket page. I do not check these forums very often. I am also open to any code contributions if someone would like to tackle this.

          1 Reply Last reply Reply Quote 4
          • PeterJonesP PeterJones referenced this topic on
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors