-
-
Notifications
You must be signed in to change notification settings - Fork 592
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
isort
ignores config files like pyproject.toml
when explicitly passing files
#1872
Comments
This is not isort's behavior intended behavior, and would represent a bug. isort is coded and tested to behave in this way the same as all other linting / formatting tools you mention. Can you provide some more information about what you are seeing? |
In particular, if you could demonstrate in a repo or docker machine exactly the behavior you are seeing in a reproducible way. The only way isort wouldn't pick up a config file, in the given examples by design, is if the settings file lives outside of either a repository that the source file is in, or does not live in a parent directory of the file (unlike the given example) which is the same behavior exhibited by these other tools. Is there any chance you are using an older version of isort? |
Prior to this change, pre-commit started messing up the import sorting with isort. It appears to have een picking up the configuration from `configfiles/.editorconfig` instead of `setup.cfg`. It appears that this is related to PyCQA/isort#1872 and PyCQA/isort#1907. This change explicitly sets the settings file to ensure the right file is used. We also fix the incorrect imports.
Prior to this change, pre-commit started messing up the import sorting with isort. It appears to have been picking up the configuration from `configfiles/.editorconfig` instead of `setup.cfg`. It appears that this is related to PyCQA/isort#1872 and PyCQA/isort#1907. This change explicitly sets the settings file to ensure the right file is used. We also fix the incorrect imports.
In my tests isort ignores pyproject.toml regardless the files being passed. Example pyproject.toml: [tool.poetry]
name = "isort_test"
version = "0.1.0"
description = ""
authors = ["Python Developer <[email protected]>"]
[tool.poetry.dependencies]
python = "^3.8"
[tool.poetry.dev-dependencies]
isort = "^5.10.1"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.isort]
line_length = 120
profile = "black"
reverse_relative = 1
src_paths = ["."] bash poetry install
poetry run isort . --show-config | less # search for line_length and you will find 79 This also causes false positives, when using pre-commit: .pre-commit-config.yaml exclude: 'docs|node_modules|.git|.tox'
default_stages: [commit]
fail_fast: true
repos:
- repo: https://github.com/timothycrosley/isort
rev: 5.10.1
hooks:
- id: isort bash pre-commit run --all-files |
Hey @timothycrosley, I recently ran into this same issue. So I created this repository to reproduce the issue: https://github.com/zeshuaro/isort-exclude-demo In the repository, If you try to run Black had the exact same issue, and the workarounds are listed in this comment: psf/black#1584 (comment). At the end, they added a Would it be possible for isort to add the same function? |
We are experiencing same issue in |
I get the following error when isort is run from windows commandline. UserWarning: Failed to pull configuration information When I add a print statement in the code \lib\site-packages\isort\settings.py it shows that it reads the info from the pyproject.toml file. running python=3.9.12 my pyproject.toml file.
|
I have the same issue. |
I experienced the same error while dealing with |
I am running into the same issue :( Some one from the maintainers should remove the
repo_needed
|
I noticed that
isort
ignores config files as soon as any arguments are passed in on the command line.Is this really the desired behavior? Especially when
isort
is called on a specific file only it is very counterintuitive that config files likepyproject.toml
are ignored, i.e.,will ignore my toml file at
./pyproject.toml
whilewill load the configuration from the toml file.
I have noticed this discrepancy while using
isort
with thepre-commit
framework. Depending on howpre-commit
is called it might actually call the tools individually on each file, e.g., when called viapre-commit run --from-ref main --to-ref HEAD
. In this caseisort
won't load the configuration.This is unlike most other linting/quality check tools like
flake8
,black
, orpylint
that will still load the configuration files.And while I can still explicitly pass in the config file via
it's still quite unintuitive and should at least be documented.
The text was updated successfully, but these errors were encountered: