timothycrosley on develop
Add Fixed #1631: as import comm… (compare)
timothycrosley on 1631
timothycrosley on develop
Add test case for issue #1631 Update output to take into acco… Update output to respect as imp… and 5 more (compare)
timothycrosley on 1631
Fix integration test (compare)
I've implemented a solution for your issue in the latest hot fix release: timothycrosley/isort#938
That's great!
@timothycrosley Could you give me a minimal example on how to use the --virtual-env
flag? Consider the
following hierarchy:
.
├── my_project
│ └── first_party_module.py
└── my_virtual_env
├── bin
│ ├── isort
│ └── python
└── lib
└── python3.6
└── site-packages
└── third_party_package.py
From timothycrosley/isort#659 I learned that the path has to be relative to my_project
. Assume my current working directory is my_project
. What do I pass to --virtual-env
?
../my_virtual_env
../my_virtual_env/bin
../my_virtual_env/lib
../my_virtual_env/lib/python3.6
../my_virtual_env/lib/python3.6/site-packages
posixpath
was changed from STDLIB to 3rd-party section (this is the pre-commit config file https://github.com/ibis-project/ibis/blob/master/.pre-commit-config.yaml#L7)
First timer contributor
want to work on issue timothycrosley/isort#941
Hi @Shrirang97 Awesome! I'm excited to merge it in! Let me know if I can help you in any way and thanks for contributing to isort!
import wrap_modes
print(wrap_modes.noqa(
**{
"comment_prefix": "-\U000bf82c\x0c\U0004608f\x10%",
"comments": [],
"imports": ['pandas','tensorflow'],
"include_trailing_comma": False,
"indent": "0\x19",
"line_length": -19659,
"line_separator": "\x15\x0b\U00086494\x1d\U000e00a2\U000ee216\U0006708a\x03\x1f",
"remove_comments": False,
"statement": "\U00092452",
"white_space": "\U000a7322\U000c20e3-\U0010eae4\x07\x14\U0007d486",
}
))
File "/home/philip/github/pystiche_papers/.venv/bin/isort", line 8, in <module>
sys.exit(main())
File "/home/philip/github/pystiche_papers/.venv/lib/python3.6/site-packages/isort/main.py", line 813, in main
for sort_attempt in attempt_iterator:
File "/home/philip/github/pystiche_papers/.venv/lib/python3.6/site-packages/isort/main.py", line 802, in <genexpr>
sort_imports( # type: ignore
File "/home/philip/github/pystiche_papers/.venv/lib/python3.6/site-packages/isort/main.py", line 120, in iter_source_code
if is_python_file(filepath):
File "/home/philip/github/pystiche_papers/.venv/lib/python3.6/site-packages/isort/main.py", line 61, in is_python_file
line = fp.readline(100)
KeyboardInterrupt
setup.py
files (along with my project's setup.py
file), what's the best way to determine whether something is a third-party dependency or not for the plugins? I have an .isort.cfg
in the root.
Thanks @timothycrosley The repo has 2 isort.cfg
files: One in a plugins
folder with six standalone packages and the other at the root, and it uses nox
for linting and plugin detection. I removed the config file in plugins
because from my understanding of the 5+ upgrade guide, there should now only be one, is this right? Please see this issue for a better understanding: facebookresearch/hydra#751 . I apologize in advance for the lengthy post :-)
For your reference, here are the current config files:
# .isort.cfg at the root directory
[settings]
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
use_parentheses=True
line_length=88
ensure_newline_before_comments=True
known_third_party=omegaconf,ray,pytest,typing_extensions
known_first_party=hydra
skip=
plugins
,.nox
,hydra/grammar/gen
,tools/configen/example/gen
,tools/configen/tests/test_modules/expected
# .isort.cfg in plugins/
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
use_parentheses=True
line_length=88
ensure_newline_before_comments=True
known_third_party=hydra,omegaconf
known_first_party=hydra_plugins
Here is the current isort.cfg
in root before your feedback (trying to combine both config's). Since section defaults is now THIRDPARTY
, I removed the known_third_party
option.
[settings]
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
use_parentheses=True
float_to_top = true
line_length=88
ensure_newline_before_comments=True
sections=
FUTURE
STDLIB
FRAMEWORK
THIRDPARTY
FIRSTPARTY
LOCALFOLDER
known_first_party=hydra,hydra_plugins
skip=
plugins
,.nox
,hydra/grammar/gen
,tools/configen/example/gen
,tools/configen/tests/test_modules/expected
And after your feedback
[settings]
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
use_parentheses=True
float_to_top = true
line_length=88
ensure_newline_before_comments=True
sections=
FUTURE
STDLIB
FRAMEWORK
THIRDPARTY
FIRSTPARTY
LOCALFOLDER
known_first_party=hydra
src_paths=
hydra_ax_sweeper
,hydra_colorlog
,hydra_joblib_launcher
,hydra_nevergrad_sweeper
,hydra_rq_launcher
,hydra_submitit_launcher
skip=
plugins
,.nox
,hydra/grammar/gen
,tools/configen/example/gen
,tools/configen/tests/test_modules/expected
I think I've gone insane. All my configs I have
[tool.isort]
multi_line_import = 3
include_trailing_comma = true
And it's worked! But I just upgraded to isort5 and it broke. I found that multi_line_import is not the correct arg name..... but my question is why was it working before because it looks like it never should have worked like that....