Giter Site home page Giter Site logo

Comments (8)

bje- avatar bje- commented on September 28, 2024 1

Many thanks for getting to the bottom of this.

from isort.

Helveg avatar Helveg commented on September 28, 2024

How exactly did you set line_length? Did you set it for black or for isort?

from isort.

bje- avatar bje- commented on September 28, 2024

isort, shown with isort --show-config.

from isort.

Helveg avatar Helveg commented on September 28, 2024

I can't reproduce your issue, with either the following Python snippet:

import isort
code = """from nemo.polygons import (WILDCARD, cst_limit, offshore_wind_limit,
                           pv_limit, wind_limit)"""
isort.code(code, profile="black", line_length=79)

or the following bash snippet:

printf "from nemo.polygons import (WILDCARD, cst_limit, offshore_wind_limit,\n                  pv_limit, wind_limit)" | isort --profile=black --line-length=79 -

the output is always:

from nemo.polygons import (
    WILDCARD,
    cst_limit,
    offshore_wind_limit,
    pv_limit,
    wind_limit,
)

Is your isort version up to date? If so, can you try passing the arguments like shown in my snippets. If none of that works, could you fully reproduce how you are setting and verifying the isort settings?

from isort.

bje- avatar bje- commented on September 28, 2024

isort --version says 5.13.2.

isort --show-config | grep line_length says:

    "line_length": 79,

Your bash snippet works for me, but if I remove the explicit --line-length argument and rely on what is shown in the config output:

printf "from nemo.polygons import (WILDCARD, cst_limit, offshore_wind_limit,\n                  pv_limit,
wind_limit)" | isort --profile=black  -

produces:

from nemo.polygons import WILDCARD, cst_limit, offshore_wind_limit, pv_limit, wind_limit

from isort.

Helveg avatar Helveg commented on September 28, 2024

Ok, can you provide me everything I need to set my config exactly the same way?

from isort.

bje- avatar bje- commented on September 28, 2024
python3 -m venv myenv
. myenv/bin/activate
pip install isort
printf "from nemo.polygons import (WILDCARD, cst_limit, offshore_wind_limit,\n                  pv_limit,
wind_limit)" | isort --profile=black  -

from isort.

Helveg avatar Helveg commented on September 28, 2024

Ok, so you're not actually setting isort's line_length to anything. In that case everything is working as expected:

The default line_length is indeed 79 characters, which is what isort --show-config shows you. But during the command you are using --profile=black. Using isort --show-config --profile=black you will see that that profile sets a line_length of 88. And the line you produce is not 89, but 88 characters long:

isort --show-config --profile=black
{
  ...
   "line_length": 88,
  ...
}

you can test this by adding 1 character _ to the last import:

printf "from nemo.polygons import (WILDCARD, cst_limit, offshore_wind_limit,\n
         pv_limit,
wind_limit_)" | isort --profile=black  -
from nemo.polygons import (
    WILDCARD,
    cst_limit,
    offshore_wind_limit,
    pv_limit,
    wind_limit_,
)

As you can see, everything is working as expected, your test input just happened to be in the Goldilock zone to mislead you 😂 Keep in mind that the profile option works by setting configuration options. These are the options that the black profile sets:

black = {
    "multi_line_output": 3,
    "include_trailing_comma": True,
    "force_grid_wrap": 0,
    "use_parentheses": True,
    "ensure_newline_before_comments": True,
    "line_length": 88,
}

from isort.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.