Skip to content

isort randomly ignores its configuration from setup.cfg #3306

Closed

Description

@lig

Environment data

  • VS Code version: 1.28.2 / 7f3ce96ff4729c91352ae6def877e59c561f4850 / x64
  • Extension version (available under the Extensions sidebar): 2018.10.1
  • OS and version: GNU/Linux Fedora 29 Linux 4.18.17-300.fc29.x86_64
  • Python version (& distribution if applicable, e.g. Anaconda): Python 2.7.15 (Also Python 3.7.1)
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): pipenv, version 2018.10.13, with Python 3.6.6
  • Relevant/affected Python packages and their versions: Builtin isort

Actual behavior

Isort configuration is defined in the [isort] section of the setup.cfg file in the root dir of one of folders in the workspace.

Using "Organize imports" sometimes, most notably after fresh VS Code start, acts like there is no configuration provided in the setup.cfg file. After some time, usually dozens of minutes, "Organize imports" starts to work properly.

Expected behavior

"Organize imports" should always obey the configuration provided in the setup.cfg file.

Steps to reproduce:

  1. Start VS Code with workspace automatically loaded.
  2. Open *.py file from the folder having setup.cfg with [isort] section.
  3. Type some code altering import statements in a way expected to be corrected by isort differently with and without custom configuration, i.e. provide a custom value for line_length and/or lines_after_imports options.
  4. Invoke "Organize imports"

Logs

Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

No output

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

No output

Edit: see updates below

Activity

  1. phwh commented on Nov 12, 2018

    @phwh

    I have the same issue. I tried passing the --settings-path argument to isort via the projects' workspace settings and it seems to be working more reliable now.

    "python.sortImports.args": [
            "--settings-path=/Users/..."
    ]
    

    Of course this is only a workaround.

  2. lig commented on Nov 12, 2018

    @lig
    Author

    Philipp Weidenhiller (@phwh) thanks! will try that after I'm able to catch more logs on that

  3. lig commented on Nov 12, 2018

    @lig
    Author

    Update

    I was able to reproduce this one.

    Reproduces randomly after has been working properly in the same session.

    I've was able to reproduce with output and dev-tools open. No output there at all when invoking "Organize imports" command.

  4. lig commented on Nov 12, 2018

    @lig
    Author

    Update

    Getting more constant behavior at the moment. It looks like invoking "Organize imports" on an unsaved file will result in the incorrect behavior. However, saving the file and applying "Organize imports" after that works as expected.

  5. DonJayamanne commented on Nov 12, 2018

    @DonJayamanne

    Closing in favor of #2980

  6. lig commented on Nov 12, 2018

    @lig
    Author

    Don Jayamanne (@DonJayamanne) Also, in this case, the command works but ignores the configuration. This unpredicted behavior shouldn't exist. Either it should work as expected or shouldn't work at all.

  7. DonJayamanne commented on Nov 12, 2018

    @DonJayamanne

    Either it should work as expected or shouldn't work at all.

    That's precisely why this issue has been closed in favor of #2980 (see the comments in that issue We should notify users that the command does not work )

  8. lig commented on Nov 12, 2018

    @lig
    Author

    Don Jayamanne (@DonJayamanne) According to comments at #2980, that's unclear that this is the actual intent at the moment.

  9. DonJayamanne commented on Nov 12, 2018

    @DonJayamanne

    that's unclear that this is the actual intent at the moment.

    That's why the issue is open. We need to make a decision.

  10. locked as resolved and limited conversation to collaborators on Dec 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions