Closed HarrisonWilde closed 10 months ago
Ok, adding --known-first-party mypackage
arguments to the extension settings appendage fixes this problem.
Feel free to close this issue. However, I find it odd that there would be this discrepancy as this is not required when running isort
directly.
The discrepancy is quite possibly due to isort
; we have discovered multiple places where isort
operates differently when run against a file path compared to having code passed in via stdin
(which is the default when using a language server).
We actually recommend people try our ruff
as it supports isort
-compatible import sorting, is extremely fast, and has a great VS Code extension: https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff .
I am currently developing a package. When I use absolute imports within the package to import other parts of the package (e.g.
from mypackage.module import x
), isort on save from VSCode sorts these imports into the 3rd party package "section" at the top of the file. However, when I runisort
explicitly on the command line on the same project, the absolute imports of parts of my package are separated from the third party ones. This is quite an annoying inconsistency as every time I commit I end up getting a warning from my pre-commit hooks.The only config I have for isort is this in my
pyproject.toml
:This is the pre-commit config: