Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip_glob does not work the same in isort 5 (vs isort 4) #1468

Closed
AlexandreYang opened this issue Sep 9, 2020 · 2 comments
Closed

skip_glob does not work the same in isort 5 (vs isort 4) #1468

AlexandreYang opened this issue Sep 9, 2020 · 2 comments

Comments

@AlexandreYang
Copy link
Contributor

Hi,

In the following setup, isort v5 is not working as expected. It's working fine with isort v4.

skip_glob declared in pyproject.toml is not working correctly for isort v5.

Setup

§ tree .  # <ROOT>
.
├── pyproject.toml
└── tokumx
    └── datadog_checks
        └── tokumx
            └── vendor
                └── code.py

Content of code.py

import json
import bar

Content of pyproject.toml

[tool.isort]
skip_glob = 'datadog_checks/*/vendor/*'

Command

With isort 5.5.1

$ cd <ROOT>/tokumx
$ isort . --check-only
ERROR: <PATH>/tokumx/datadog_checks/tokumx/vendor/code.py Imports are incorrectly sorted and/or formatted.

With isort 4.3.21

$ cd <ROOT>/tokumx
$ isort --check-only
Skipped 1 files

Notes for isort 5.5.1

Using --skip-glob as command line argument does not work if skip_glob is not present in pyproject.toml. But it does work, if absent.

Without skip_glob in pyproject.toml:

$ cd <ROOT>/tokumx
$ isort . --check-only --skip-glob 'datadog_checks/*/vendor/*'
Skipped 1 files

With skip_glob = 'datadog_checks/*/vendor/*' in pyproject.toml:

$ cd <ROOT>/tokumx
$ isort . --check-only
ERROR: <PATH>/tokumx/datadog_checks/tokumx/vendor/code.py Imports are incorrectly sorted and/or formatted.

Real life case:

https://dev.azure.com/datadoghq/integrations-core/_build/results?buildId=23283&view=logs&jobId=1a934b33-5d6c-528e-b666-73479c7a7fd1&j=1a934b33-5d6c-528e-b666-73479c7a7fd1&t=d7570bc9-350e-55d5-cbd3-a5ab30f91435

Related PR: DataDog/integrations-core#7539

@timothycrosley
Copy link
Member

Hi @AlexandreYang,

Thanks for reporting this issue! I believe the error here is that all skips were explicitly made relative to the config file location in 5.x.x, with no implied initial star. All that means for your configuration is that a star would be need to be placed before each glob for it to match, changing the config value to:

skip_glob = '*/datadog_checks/dev/tooling/signing.py,*/datadog_checks/dev/tooling/templates/*,*/datadog_checks/*/vendor/*'

If this works for you, I'll make sure the documentation is updated to reflect this.

Thanks!

~Timothy

@AlexandreYang
Copy link
Contributor Author

@timothycrosley Make sense, your suggestion works. 👍

Thanks for updating the doc about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants