Skip to content

Issue with import ordering per pyproject.toml #1

@ethagnawl

Description

@ethagnawl

First of all, thank you so much for putting this project together. I was banging my head against my desk for hours trying to get Syntastic (I know ...) and Autoformat working with Ruff and your project worked on the first try. It'll take a day or two to get used to the new commands but I can't be bothered to revisit the janky things I was doing to shim Ruff into my crusty old workflow. (I swear I could have written your Motivation section myself. 😝)

Anyways! While the basics are working as expected, I'm now trying to use this plugin in a project and am seeing a potential issue with the rules defined in pyproject.toml. I have verified that both running ruff check --select I app/some/file.py and our CI job are sorting imports correctly according to the config but my usage of this plugin is not. This could very well be an issue on my end, as this is all new to me.

I have verified that the plugin is loading pyproject.toml as expected. After adding a print statement, I see the following when running :Ruff:

{'tool': {'black': {'line-length': 88, 'exclude': '/(\n  | migrations\n  | .venv\n  | .git\n)/\n'}, 'ruff': {'select': ['I', 'F401', 'E4', 'E7', 'E9', 'F'], 'line-length': 88, 'exclude': ['management', 'migrations
', '.git', '.venv', '_scratch.py'], 'isort': {'force-single-line': False, 'combine-as-imports': True, 'case-sensitive': True, 'lines-after-imports': -1, 'lines-between-types': 1, 'order-by-type': False, 'from-firs
t': False, 'section-order': ['future', 'standard-library', 'django', 'strawberry', 'third-party', 'first-party', 'local-folder'], 'known-first-party': ['tenant_app', 'tenant_models', 'public_models'], 'known-third
-party': ['loguru'], 'default-section': 'third-party', 'force-wrap-aliases': True, 'sections': {'django': ['django'], 'strawberry': ['strawberry', 'strawberry_django']}}}}}

The result displayed on the left in this screenshot is what gets produced by this plugin and on the right is what is produced by invoking ruff on the CLI. (This screenshot is our CI job "fixing" my ordering.)

Image

This is the relevant bit of my .vimrc

let g:vimruff_default = "both"
let g:vimruff_check_select = "I"

Interestingly, I've verified that if I hardcode the path to both my pyproject.toml and the file I'm trying to check into ruff_check then it does detect the "error" but it dumps that output into my Vim buffer. (This may be related to your comment 'ruff check --fix -' on error returns the whole input via stdout)

So, am I doing anything obviously wrong in my use of this plugin? Is there any additional information I can provide? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions