sublimelsp / LSP-ruff

LSP helper for ruff - an extremely fast Python linter, written in Rust.

Home Page:https://packagecontrol.io/packages/LSP-ruff

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unexpected argument '--format'

TimCarbo opened this issue · comments

commented

Ruff does not work and logs the following:

LSP-ruff: Workspace settings: {
    "args": [
        "--check"
    ],
    "logLevel": "debug",
    "path": []
}
LSP-ruff: Global settings: {
    "interpreter": [],
    "showNotification": "off",
    "fixAll": true,
    "organizeImports": true,
    "args": [
        "--check"
    ],
    "logLevel": "error",
    "path": []
}
:: [10:55:29.010] <-  LSP-ruff window/logMessage: {'message': 'Workspace settings: {\n    "args": [\n        "--check"\n    ],\n    "logLevel": "debug",\n    "path": []\n}', 'type': 4}
:: [10:55:29.010] <-  LSP-ruff window/logMessage: {'message': 'Global settings: {\n    "interpreter": [],\n    "showNotification": "off",\n    "fixAll": true,\n    "organizeImports": true,\n    "args": [\n        "--check"\n    ],\n    "logLevel": "error",\n    "path": []\n}', 'type': 4}
:: [10:55:29.021] <<< LSP-ruff (1) (duration: 612ms): {'capabilities': {'workspace': {'fileOperations': {}, 'workspaceFolders': {'supported': True, 'changeNotifications': True}}, 'hoverProvider': True, 'executeCommandProvider': {'commands': ['ruff.applyAutofix', 'ruff.applyOrganizeImports']}, 'textDocumentSync': {'save': {}, 'didOpen': {}, 'change': {'syncKind': 2}, 'didClose': {}}, 'codeActionProvider': {'codeActionKinds': ['quickfix', 'source.fixAll', 'source.organizeImports', 'source.fixAll.ruff', 'source.organizeImports.ruff'], 'resolveProvider': True}, 'positionEncoding': 'utf-16'}, 'serverInfo': {'version': '0.0.39', 'name': 'Ruff'}}
:: [10:55:29.022]  -> LSP-ruff initialized: {}
:: [10:55:29.026]  -> LSP-ruff textDocument/didOpen: {'textDocument': {'version': 0, 'text': '...', 'languageId': 'python', 'uri': 'file:///home/...'}}
LSP-ruff: Using interpreter executable: /home/.cache/sublime-text/Package Storage/LSP-ruff/bin/ruff
LSP-ruff: Running Ruff with: /home/.cache/sublime-text/Package Storage/LSP-ruff/bin/ruff ['--force-exclude', '--no-cache', '--no-fix', '--quiet', '--format', 'json', '-', '--check', '--stdin-filename', '...']
:: [10:55:29.031] <-  LSP-ruff window/logMessage: {'message': 'Using interpreter executable: /home/.cache/sublime-text/Package Storage/LSP-ruff/bin/ruff', 'type': 4}
:: [10:55:29.031] <-  LSP-ruff window/logMessage: {'message': "Running Ruff with: /home/.cache/sublime-text/Package Storage/LSP-ruff/bin/ruff ['--force-exclude', '--no-cache', '--no-fix', '--quiet', '--format', 'json', '-', '--check', '--stdin-filename', '...']", 'type': 4}
LSP-ruff: error: unexpected argument '--format' found

  tip: to pass '--format' as a value, use '-- --format'

Usage: ruff 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|--config <CONFIG>|--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|--isolated|--cache-dir <CACHE_DIR>|--stdin-filename <STDIN_FILENAME>|--exit-zero|--exit-non-zero-on-fix|--statistics|--add-noqa|--show-files|--show-settings|--ecosystem-ci> <--verbose|--quiet|--silent>

For more information, try '--help'.

:: [10:55:29.041] <-  LSP-ruff window/logMessage: {'message': "error: unexpected argument '--format' found\n\n  tip: to pass '--format' as a value, use '-- --format'\n\nUsage: ruff 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|--config <CONFIG>|--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|--isolated|--cache-dir <CACHE_DIR>|--stdin-filename <STDIN_FILENAME>|--exit-zero|--exit-non-zero-on-fix|--statistics|--add-noqa|--show-files|--show-settings|--ecosystem-ci> <--verbose|--quiet|--silent>\n\nFor more information, try '--help'.\n", 'type': 4}
:: [10:55:29.042] <-  LSP-ruff textDocument/publishDiagnostics: {'diagnostics': [], 'uri': 'file:///...'}

I tried overriding args in my project's and global config but the wrong ones keep being passed.

Versions:
Sublime Text Build 4152
ruff 0.1.1 according to ruff --version
ruff 0.0.39 according to the logs serverInfo.version
Python 3.11.4
LSP 1.25.0
LSP-ruff 1.0.10

I was able to replicate

:: [23:53:38.354] <-  LSP-ruff window/logMessage: {'message': 'Using interpreter executable: /Users/dvitto/Library/Caches/Sublime Text/Package Storage/LSP-ruff/bin/ruff', 'type': 4}
:: [23:53:38.354] <-  LSP-ruff window/logMessage: {'message': "Running Ruff with: /Users/dvitto/Library/Caches/Sublime Text/Package Storage/LSP-ruff/bin/ruff ['--force-exclude', '--no-cache', '--no-fix', '--quiet', '--format', 'json', '-', '--fix', '--extend-ignore', 'ALL', '--extend-select', 'I001', '--stdin-filename', '/Users/dvitto/projects/cerrada-movie-summary/summary.py']", 'type': 4}
LSP-ruff: error: unexpected argument '--format' found

  tip: to pass '--format' as a value, use '-- --format'

ruff 0.1.1 according to ruff --version
ruff 0.0.39 according to the logs 
Sublime Text build `4152 ` 

I found this on ruff's change log, so it makes sense, the --format should now be --output-format

True, I can see it in the log:

:: [01:30:09.239] <<< LSP-ruff (1) (duration: 780ms): {
    'capabilities': {
        'codeActionProvider': {
            'resolveProvider': True, 
            'codeActionKinds': ['quickfix', 'source.fixAll', 'source.organizeImports', 'source.fixAll.ruff', 'source.organizeImports.ruff']
        }, 
        'hoverProvider': True, 
        'positionEncoding': 'utf-16', 
        'workspace': {
            'workspaceFolders': {
                'supported': True, 
                'changeNotifications': True
            }, 
            'fileOperations': {}
        }, 
        'textDocumentSync': {
            'change': {
                'syncKind': 2
            }, 
            'save': {}, 
            'didOpen': {}, 
            'didClose': {}
        }, 
        'executeCommandProvider': {
            'commands': ['ruff.applyAutofix', 'ruff.applyOrganizeImports']
        }
    }, 
    'serverInfo': {'version': '0.0.39', 'name': 'Ruff'}
}

But I am confused then, why did it suddenly stop working?

Because your system ruff was probably updated to > 0.1
This will be fixed once the ruff-lsp dependency is bumped to 0.0.41.
See astral-sh/ruff-lsp@55568c4

Pushed 0.0.41 just now. Should be on Package Control within a few hours.

commented

It works, thanks a lot !