Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Python Indent plugin not working correctly?

    Help wanted · · · – – – · · ·
    8
    23
    4298
    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 Haymes
      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 Vincent
        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 Brown
          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
          • Referenced by  PeterJones PeterJones 
          • First post
            Last post
          Copyright © 2014 NodeBB Forums | Contributors