Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • May 24 02:14
    PythonCoderAS opened #1938
  • May 24 02:11
    PythonCoderAS opened #1937
  • May 20 06:58

    timothycrosley on main

    Fix typeshed integration test (compare)

  • May 19 06:26

    timothycrosley on main

    Fix pylint integration test (compare)

  • May 19 03:33
    machallboyd commented #1908
  • May 18 09:29
    jamiesandenr commented #1813
  • May 18 06:47

    timothycrosley on main

    Fix hypothesis integration test (compare)

  • May 16 11:49
    a-t-0 commented #1518
  • May 16 07:11

    timothycrosley on main

    Fix name of skipped file (compare)

  • May 16 06:59

    timothycrosley on main

    Fix zope integration test (compare)

  • May 16 03:24
    onerandomusername unassigned #1683
  • May 15 14:21
    alexey-tereshenkov-oxb opened #1936
  • May 15 06:08

    timothycrosley on main

    black (compare)

  • May 13 21:36

    timothycrosley on main

    Add magic trailing comma option Merge branch 'PyCQA:main' into … Merge branch 'main' into traili… and 1 more (compare)

  • May 13 21:36
    timothycrosley closed #1876
  • May 13 21:36
    timothycrosley closed #1683
  • May 13 14:31
    gbolmier opened #1935
  • May 12 21:14

    timothycrosley on main

    poetry update Ignore some safety errors for n… (compare)

  • May 12 09:23
    He3lixxx commented #1912
  • May 12 09:17
    He3lixxx edited #1912
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
graingert
@graingert:matrix.org
[m]
hello, I tried https://github.com/twisted/twisted/pull/1655/commits/e9b73724835fab6a735647f38a8418260c3b17cc to special case twisted.internet.reactor but isort didn't group it, am I misconfiguring something or is this a new feature I need?
Thomas Grainger
@graingert
:point_up: August 6, 2021 7:53 AM @timothycrosley
Anderson Bravalheri
@abravalheri

Hi guys, I recently asked a question in the issue tracker, but I just realised this chat exists (maybe this would be a better forum). So here it goes:

Is there any way to force a sub-package to be separated to another group?

In one project I am vendoring an external dependency (because I need to apply some patches to it before using), so I have a project layout similar to the following:

.
└── src
    └── <mypkg>
        ├── __init__.py
        ├── ...
        └── _vendor
            ├── __init__.py
            ├── <deppkg>
            │   ├── LICENSE
            │   ├── ...
            │   └── __init__.py
            └── vendoring_instructions.rst

I would like to have my from ._vendor import ... import statements separated from the imports of the local package (from . import ...).

Is there any way of achieving that by changing isort's configuration?

I tried the following:

# .isort.cfg
[settings]
profile = black
known_first_party = <mypkg>
known_third_party = ._vendor
# ALSO TRIED: known_third_party = <mypkg>._vendor
# ALSO TRIED: known_third_party = _vendor

But that does not seem to pull of the trick (or maybe I am doing something wrong here).

(BTW, thank you very much Timothy and all contributors and maintainer, I have been using isort for years, and I simply love it)