omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Change black linelength

    Pythonista
    3
    11
    161
    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.
    • upwart
      upwart last edited by

      I would like to reformat with black with another line length than the default of 88.
      I know that this is in black/const.py, but this seems to be read only.
      How can I change const.py, copy black completely or give command line parameters in the reformat command. Or ...?

      ccc 1 Reply Last reply Reply Quote 0
      • ccc
        ccc @upwart last edited by

        @upwart Perhaps a pyproject.toml file with the right settings? I did not try that but it might work.

        upwart 1 Reply Last reply Reply Quote 0
        • upwart
          upwart @ccc last edited by upwart

          @ccc
          That's a good suggestion.
          I tried putting a proper pyproject.toml in the folder where the to-be-reformatted file resides or the parent folder. But it doesn't work.
          @omz
          It would be nice if I just could edit a file in the site-packages (built-in) , but that folder is obviously readonly. Making that folder read/write would also allow patches in other built in modules.

          ccc 1 Reply Last reply Reply Quote 0
          • ccc
            ccc @upwart last edited by

            @upwart please see the psf/black docs to see what other config files they support.

            upwart 1 Reply Last reply Reply Quote 0
            • upwart
              upwart @ccc last edited by

              @ccc
              As far as I can see only pyproject.toml or command line parameters are supported. And changing const.py.
              But none of these seem to be possible in Pythonista. Pitty!

              cvp upwart 2 Replies Last reply Reply Quote 0
              • cvp
                cvp @upwart last edited by cvp

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • upwart
                  upwart @upwart last edited by

                  This is to tell that I have managed to get black to use an alternative line length (160 in my case), by pip installing black. It will be installed in the site-packages (user) folder. And there, I can just patch the const.py file.
                  It seems to work perfectly. Hooray!

                  ccc 1 Reply Last reply Reply Quote 1
                  • ccc
                    ccc @upwart last edited by

                    ruff.toml did not work?

                    upwart 1 Reply Last reply Reply Quote 0
                    • upwart
                      upwart @ccc last edited by

                      @ccc
                      What do you mean with ruff.toml?
                      I tried pyproject.toml, but could get that working.

                      cvp 1 Reply Last reply Reply Quote 0
                      • cvp
                        cvp @upwart last edited by

                        @upwart I don't know anything but this advice comes perhaps from this

                        upwart 1 Reply Last reply Reply Quote 0
                        • upwart
                          upwart @cvp last edited by

                          @cvp
                          Thanks for thinking with me.
                          I know how to add the Black section to pyproject.toml. Just can't work out where to put it in Pythonista to work with reformat.
                          Anyway, I've it working now via a user installation of Back.

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post
                          Powered by NodeBB Forums | Contributors