astral-sh / ruff-vscode

A Visual Studio Code extension with support for the Ruff linter.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error using --extend-include setting, though it's being respected in highlighting.

wojtekjakubo opened this issue · comments

Hello!

I'm using VSCode-MotionBuilder-Utils to write python scripts for MotionBuilder DCC app. It uses stubs and it's setting in the settings.json is:

"python.analysis.extraPaths": [
        "C:/Users/wjakubowski/AppData/Roaming/VSCode-MotionBuilder-Utils/stubs"
    ]

After i installed Ruff all the "pyfbsdk" module imports were highlighted as not recognized.

I've added:

"ruff.lint.args": [
         "--extend-include=c:/Users/wjakubowski/AppData/Roaming/VSCode-MotionBuilder-Utils/stubs/*.*"
    ],

to settings, and after restart it's properly highlighting the module imports, but it constantly throws notification errors about:

Ruff: Lint failed (error: unexpected argument '--extend-include' found

  tip: a similar argument exists: '--extend-exclude'

Usage: ruff.exe check <FILES|--fix|--no-fix|--unsafe-fixes|--no-unsafe-fixes|--show-source|--no-show-source|--show-fixes|--no-show-fixes|--diff|--watch|--fix-only|--no-fix-only|--ignore-noqa|--output-format <OUTPUT_FORMAT>|--output-file <OUTPUT_FILE>|--target-version <TARGET_VERSION>|--preview|--no-preview|--select <RULE_CODE>|--ignore <RULE_CODE>|--extend-select <RULE_CODE>|--extend-ignore <RULE_CODE>|--per-file-ignores <PER_FILE_IGNORES>|--extend-per-file-ignores <EXTEND_PER_FILE_IGNORES>|--exclude <FILE_PATTERN>|--extend-exclude <FILE_PATTERN>|--fixable <RULE_CODE>|--unfixable <RULE_CODE>|--extend-fixable <RULE_CODE>|--extend-unfixable <RULE_CODE>|--respect-gitignore|--no-respect-gitignore|--force-exclude|--no-force-exclude|--line-length <LINE_LENGTH>|--dummy-variable-rgx <DUMMY_VARIABLE_RGX>|--no-cache|--cache-dir <CACHE_DIR>|--stdin-filename <STDIN_FILENAME>|--extension <EXTENSION>|--exit-zero|--exit-non-zero-on-fix|--statistics|--add-noqa|--show-files|--show-settings|--ecosystem-ci> <--verbose|--quiet|--silent>

For more information, try '--help'.
)

When i tried to create a custom ruff.toml file with that option:

[lint]
extend-include = ["c:/Users/wjakubowski/AppData/Roaming/VSCode-MotionBuilder-Utils/stubs/*.*"]

it also errors out:

Ruff: Lint failed (ruff failed
  Cause: Failed to parse c:/Users/wjakubowski/Documents/Stuff/ruff.toml
  Cause: TOML parse error at line 1, column 1
  |
1 | [lint]
  | ^^^^^^^
unknown field `extend-include`

)

However - it's still working - pyfbsdk modules are not highlighted with yellow, but Ruff notifications are appearing despite me turning them off.

Best regards,
Wojtek

After i installed Ruff all the "pyfbsdk" module imports were highlighted as not recognized.

Highlighted by which tool? Was Ruff raising a diagnostic?

(Ruff doesn't resolve imports, so this seems like it may have been a misconfiguration of some other tool?)

Thanks for the response!

To be clear - I'm an animator and coding is my hobby so i might not be the best person to understand all the configs, sorry.

My expected behaviour is that i have VSCode plugin VSCode-MotionBuilder-Utils installed that connects the editor with Motion Builder app so i can run/debug scripts from MotionBuilder. Pre-Ruff i was using it with default VSCode python setup, and it was working fine with both pyfbsdk MotionBuilder python sdk packages. As i understand they are in form of a stub, located in that plugin path, and in VSCode config file it adds that to python via "python.analysis.extraPaths" And then i can write single file python scripts and dont worry about placing it in some weird directory only to resolve the pyfbsdk package, because this plugin does it for me.

image

But when i installed Ruff it stopped working:

image

I then searched to find a solution and added extend-include preference that will allow me to import that stubs from the VSCode-MotionBuilder-Utils plugin.

So i've added that config setting to settings.json and tried to run it - which resolved the missing pyfbsdk module, but Ruff was started to give me error notifications:

image

Same with setting that configuration in custom ruff.toml file.

So other than this error notification - the Ruff is working as expected.

I then searched to find a solution and added extend-include preference that will allow me to import that stubs from the VSCode-MotionBuilder-Utils plugin.

Ruff doesn't support extend-include via the command-line which is what you're doing. But, I see that you're using it in the config file as well where you're seeing errors.

Can you provide the Ruff VS Code extension version you're using?

ruff_vscode_extension_version

Also, it would be helpful to provide the logs from the extension. You can find it via:

how_to_pin_ruff_in_vscode_toolbar

Ok i think i know what's up.

I have:
"python.analysis.extraPaths":

in my user confing that points to *.pyi stub files. That was for Pylance. But ruff doesnt recognize that config setting, so when it errors out on that --extend-include, it's disabling the Ruff linter and i'm guessing it's defaulting to Pylance then.

Question is - how can i properly import *.pyi stub files that are in some custom directory to be recognized by Ruff?

Ok, it seems my VSCode installation was totally messed up. I got it working in the end.

Sorry for confusion.

All the best!

Glad to know it's working, thanks for informing us :)