Comments (8)
Many thanks for getting to the bottom of this.
from isort.
How exactly did you set line_length
? Did you set it for black
or for isort
?
from isort.
isort
, shown with isort --show-config
.
from isort.
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.
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.
Ok, can you provide me everything I need to set my config exactly the same way?
from isort.
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.
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)
- Circular Import Issue Due to Import Reordering in Python 3.8
- Bug : isort add empty lines before pylint comments
- Deprecate `setuptools` integration comand
- Docs: GitHub action and Pre-commit need better configuration/args examples HOT 1
- Bug: Word wrapping works incorrectly with force_single_line=True
- isort breaks the code with sort_reexports = true HOT 2
- noqa isn't well respected
- Feature request: per-block sorting strategy (inline sort)
- Isort does not honor skip directories
- `isort` does not move all imports to the top of the file when there are imports after other code blocks
- `--sort-reexports` does not respect `--profile=black` HOT 2
- isort copies comments across imports HOT 4
- Feature request: Remove superfluous `import a` statements when there is already `import a.b`
- --sort-reexports results in isort not being able to parse file
- OSS Fuzz Integration
- Unrecoverable exception thrown when parsing when parsing a module
- Long imports and noqa
- inline comments not supported in configuration file
- Searching for project_root
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from isort.