Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Nov 27 15:05
    MarcoGorelli commented #1338
  • Nov 26 11:09
    MarcoGorelli opened #1603
  • Nov 25 07:51

    timothycrosley on develop

    Update changelog (compare)

  • Nov 24 14:02
    exhuma opened #1602
  • Nov 23 19:27
    paddyroddy commented #1601
  • Nov 23 19:24
    MarcoGorelli commented #1601
  • Nov 23 19:17
    paddyroddy closed #1601
  • Nov 23 19:17
    paddyroddy commented #1601
  • Nov 23 19:15
    MarcoGorelli commented #1601
  • Nov 23 19:03
    paddyroddy opened #1601
  • Nov 23 12:32
    mgresko closed #1600
  • Nov 23 12:32
    mgresko commented #1600
  • Nov 21 12:22
    utkarshgupta137 edited #1599
  • Nov 21 12:10
    utkarshgupta137 commented #1599
  • Nov 20 14:46
    gruberrro commented #1592
  • Nov 20 14:45
    gruberrro commented #1592
  • Nov 20 06:10
    timothycrosley labeled #1600
  • Nov 20 06:09
    timothycrosley commented #1600
  • Nov 18 13:02
    mgresko edited #1600
  • Nov 18 13:01
    mgresko opened #1600
Serge Matveenko
@lig

I've implemented a solution for your issue in the latest hot fix release: timothycrosley/isort#938

That's great!

Timothy Edmund Crosley
@timothycrosley
timothycrosley/isort#1123 For pycascade sprinters
timothycrosley/isort#1125 Ticket to update documentation for command line flags, and other changes with isort 5.0.0
Isaac Philip
@isaac-philip

kindly advise for,

wish to only output diff data with exit status other than 0

Timothy Edmund Crosley
@timothycrosley
Hi @isaac-philip, I believe this should work for you isort --check --diff
Isaac Philip
@isaac-philip
Thanks @timothycrosley
I couldnt find it in the help manual, should it be added?
Olivier DOSSMANN
@blankoworld
Hi all, just a question about a configuration: is there any config parameter to change behaviour in LOCALFOLDER paragraph to place "from .file import Something" BEFORE "from ..file import Something"?
Philip Meier
@pmeier
This message was deleted
Philip Meier
@pmeier

@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
Ivan Ogasawara
@xmnlab
@timothycrosley any updates about a new release? I would be happy if I can help in any way
Ivan Ogasawara
@xmnlab
hey everyone! this week using isort with pre-commit 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)
as the isort is pinned to a specific commit ... not sure what could be the problem ... I also opened a PR pinning pre-commit to 2.1 .. but no success ... does anyone has any idea about thsi issue? PS: I will open an issue for that, just checking here first if anyone has any idea :)
Sagi Shadur
@saroad2
Hey there, do you have a new release date for v5.0.0?
Timothy Edmund Crosley
@timothycrosley
Shrirang
@Shrirang97
First timer contributor
want to work on issue timothycrosley/isort#941
Shrirang
@Shrirang97
created branch issue/941
Timothy Edmund Crosley
@timothycrosley

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!

Shrirang
@Shrirang97
@timothycrosley I need your help to understand each input parameter for wrap_modes
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",
            }
        ))
Timothy Edmund Crosley
@timothycrosley
@Shrirang97 , This must be the output of one of the autogenerated tests right?
They are meant to find unexpected errors, by trying truly outrageous values
Philip Meier
@pmeier
@timothycrosley any hints how to debug what is going wrong when isort gets stuck? I'm in the process to upgrading to isort==5.2.0and simply running isort . in my project root will get stuck after a few files.
Manually aborting gets me the following trace:
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
Timothy Edmund Crosley
@timothycrosley
@pmeier That sounds like an awful experience! I've never seen this before, but I was able to create a scenerio in which it could happen if I had recursive symbolic links since by default isort follows symbolic links
is it possible you have any in your project?
Timothy Edmund Crosley
@timothycrosley
If it is an issue caused by recursive symbolic links, the just released 5.2.1 update, which adds recursive link protection, should resolve your issue
Philip Meier
@pmeier
@timothycrosley 5.2.1 does not fix the problem. I just tried running it in a fresh clone and here it works fine. I guess I did something weird in my setup. I'll try to figure out what is going on and get back to you if I get stuck again.
Timothy Edmund Crosley
@timothycrosley
Glad to hear you got it working, but sorry it happened at all! Please let me know if it happens again, I'd love to resolve whatever case it is that you ran into
Philip Meier
@pmeier
@timothycrosley Found the offender: isort didn't hang, but was busy processing a dataset folder (~1,3 million images). I hadn't symlinked in the dataset in the fresh clone and thus it ran fine there.
Philip Meier
@pmeier
@timothycrosley I've found timothycrosley/isort#1359 while trying to fix this
Timothy Edmund Crosley
@timothycrosley
@pmeier Thanks for finding and reporting these issues!
Madhava Jay
@madhavajay
Does anyone know if isort can convert absolute imports to relative imports for the first party library?
Timothy Edmund Crosley
@timothycrosley
@madhavajay it cannot at this time
Vincent Porta
@vporta
@timothycrosley I'm upgrading to v5+. I have a project with a codebase that has multiple standalone packages/plugins with separate 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.
Timothy Edmund Crosley
@timothycrosley
@vporta Glad to hear you're upgrading to 5+! It sounds like your repository setup is very similar to the one used by datadog here: PyCQA/isort#1467
If, in a similar vein, you have a top level or a couple of top level namespaces you want to represent first_party, I would just add them to a list of first_party, like they have done, and then disable src_path based detection
If on the other hand, you need to each one of the individual projects to be included
The current "correct" way to do that, would be to add each individual package to your src_paths, however that could be too much of a hassle depending on how many of these sub packages you have.
Timothy Edmund Crosley
@timothycrosley
There is some improvent planned to the placement logic for 5.6.0 to ensure better support for namespace packages, if I can develop a complete understand of how your repo is structured, and what your end goal is, I could likely include support for it as part of that project
Vincent Porta
@vporta

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
Daniel Neal
@danrneal

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....

Timothy Edmund Crosley
@timothycrosley
@danrneal isort < 5.0.0 would silently ignore incorrectly named arguments
is it possible it was using the default grid mode for wrapping
and not mode #3 which I believe is vert-hanging
Daniel Neal
@danrneal
It was actually formatting it correctly.... and playing well with black. Maybe it had to do with how vscode was handling it...
Dylan Richardson
@dylrich
Hey all. Just wondering, is it possible to sort imports where there is a space between each file from a section? So:
from a.package import run
# put a space between these packages like so because they are different local files
from b.package import main