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

No linting is shown?

Gabriel-p opened this issue · comments

I installed almost everything but I forgot the python3.10-venv package so ST showed an error stating that something had been disabled until I installed that package. I Installed it but now I can't remember what was disabled and I have no linting at all.

Any ideas on how I can debug/fix this? Thank you!

Try restarting sublime text

I did, I have no linting at all. This is a temp file with many violations:

Captura de pantalla de 2023-03-13 09 41 48

This is the console when ST is started:

startup, version: 4143 linux x64 channel: stable
executable: /opt/sublime_text/sublime_text
application: /opt/sublime_text
working dir: /home/gabriel
packages path: /home/gabriel/.config/sublime-text/Packages
state path: /home/gabriel/.config/sublime-text/Local
zip path: /opt/sublime_text/Packages
zip path: /home/gabriel/.config/sublime-text/Installed Packages
ignored_packages: ["Anaconda", "AutoPEP8", "SublimeLinter", "Vintage", "WordHighlight"]
pre session restore time: 0.52991
loading dictionary Packages/Language - English/en_US.dic
startup time: 1.06196
git: located Sublime Merge installed at /opt/sublime_merge
git: using configuration from system git install
git: tracking working dir /media/gabriel/rest/Dropbox_nosync/Papers/2023/GDR3_members
first paint time: 1.11211
reloading plugin Default.arithmetic
reloading plugin Default.auto_indent_tag
reloading plugin Default.block
reloading plugin Default.colors
reloading plugin Default.comment
reloading plugin Default.convert_color_scheme
reloading plugin Default.convert_syntax
reloading plugin Default.copy_path
reloading plugin Default.echo
reloading plugin Default.exec
reloading plugin Default.fold
reloading plugin Default.font
reloading plugin Default.goto_line
reloading plugin Default.history_list
reloading plugin Default.html_print
reloading plugin Default.indentation
reloading plugin Default.install_package_control
reloading python 3.3 plugin 0_package_control_loader.00-package_control
reloading python 3.3 plugin 0_package_control_loader.01-pygments
reloading python 3.3 plugin 0_package_control_loader.01-sublime_lib
reloading python 3.3 plugin 0_package_control_loader.10-lsp_utils
reloading python 3.3 plugin 0_package_control_loader.50-backrefs
reloading python 3.3 plugin 0_package_control_loader.50-bracex
reloading python 3.3 plugin 0_package_control_loader.50-markupsafe
reloading python 3.3 plugin 0_package_control_loader.50-pathlib
reloading python 3.3 plugin 0_package_control_loader.50-pymdownx
reloading python 3.3 plugin 0_package_control_loader.50-python-markdown
reloading python 3.3 plugin 0_package_control_loader.50-pyyaml
reloading python 3.3 plugin 0_package_control_loader.51-python-jinja2
reloading python 3.3 plugin 0_package_control_loader.55-jsonschema
reloading python 3.3 plugin 0_package_control_loader.55-mdpopups
reloading python 3.3 plugin 0_package_control_loader.55-wcmatch
reloading python 3.3 plugin AlignTab.aligner
reloading plugin Default.keymap
reloading plugin Default.kill_ring
reloading python 3.3 plugin AlignTab.aligntab
reloading plugin Default.mark
reloading plugin Default.new_templates
reloading plugin Default.open_context_url
reloading plugin Default.open_in_browser
reloading plugin Default.pane
reloading plugin Default.paragraph
reloading python 3.3 plugin AlignTab.hist
reloading python 3.3 plugin AlignTab.parser
reloading python 3.3 plugin AlignTab.table
reloading python 3.3 plugin AlignTab.utils
reloading plugin Default.paste_from_history
reloading python 3.3 plugin AlignTab.wclen
reloading python 3.3 plugin AutoDocstring.auto_docstring
reloading plugin Default.profile
reloading plugin Default.quick_panel
reloading plugin Default.rename
reloading plugin Default.run_syntax_tests
reloading plugin Default.save_on_focus_lost
reloading plugin Default.scroll
reloading plugin Default.set_unsaved_view_name
reloading plugin Default.settings
reloading plugin Default.show_scope_name
reloading plugin Default.side_bar
reloading plugin Default.sort
reloading plugin Default.switch_file
reloading plugin Default.symbol
reloading plugin Default.transform
reloading plugin Default.transpose
reloading plugin Default.ui
reloading plugin CSS.css_completions
reloading plugin Diff.diff
reloading plugin HTML.encode_html_entities
reloading plugin HTML.html_completions
reloading python 3.3 plugin AutoDocstring.autodocstring_logging
reloading plugin ShellScript.ShellScript
reloading python 3.3 plugin AutoDocstring.docstring_styles
reloading plugin MarkdownEditing.plugin
reloading python 3.3 plugin AutoDocstring.dparse
reloading python 3.3 plugin AutoWrap.autowrap
reloading python 3.3 plugin BracketHighlighter.bh_core
reloading plugin MarkdownTOC.__init__
reloading plugin User.NewPythonFile
reloading plugin User.project_venv_repl
reloading python 3.3 plugin BracketHighlighter.bh_logging
reloading python 3.3 plugin BracketHighlighter.bh_plugin
reloading python 3.3 plugin BracketHighlighter.bh_popup
reloading python 3.3 plugin BracketHighlighter.bh_regions
reloading python 3.3 plugin BracketHighlighter.bh_remove
reloading python 3.3 plugin BracketHighlighter.bh_rules
reloading python 3.3 plugin BracketHighlighter.bh_search
reloading python 3.3 plugin BracketHighlighter.bh_swapping
reloading python 3.3 plugin BracketHighlighter.bh_wrapping
reloading python 3.3 plugin BracketHighlighter.support
reloading python 3.3 plugin GitGutter.plugin
reloading python 3.3 plugin LSP-json.commands
reloading python 3.3 plugin LSP-json.plugin
reloading python 3.3 plugin LSP-json.schema_store
reloading python 3.3 plugin LSP-ruff.plugin
reloading python 3.3 plugin LSP.boot
reloading python 3.3 plugin MarkdownPreview.browser
reloading python 3.3 plugin MarkdownPreview.markdown_preview
reloading python 3.3 plugin MarkdownPreview.markdown_settings
reloading python 3.3 plugin MarkdownPreview.markdown_wrapper
reloading python 3.3 plugin Package Control.1_reloader
reloading python 3.3 plugin Package Control.2_bootstrap
reloading python 3.3 plugin Package Control.Package Control
reloading python 3.3 plugin SyncedSideBar.SyncedSideBar
reloading python 3.3 plugin WordingStatus.WordingStatus
reloading python 3.3 plugin LaTeXTools.01_reload_submodules
reloading python 3.3 plugin LaTeXTools.02_temp_file_cleanup
reloading python 3.3 plugin LaTeXTools.03_reset_phantoms
reloading python 3.3 plugin LaTeXTools.biblatex_crossref_completions
reloading python 3.3 plugin LaTeXTools.biblatex_field_name_completions
reloading python 3.3 plugin LaTeXTools.biblatex_name_completions
reloading python 3.3 plugin LaTeXTools.biblatex_snippet_completions
reloading python 3.3 plugin LaTeXTools.biblatex_syntax_listener
reloading python 3.3 plugin LaTeXTools.change_environment
reloading python 3.3 plugin LaTeXTools.create_mousemap
reloading python 3.3 plugin LaTeXTools.delete_temp_files
reloading python 3.3 plugin LaTeXTools.detect_spellcheck
reloading python 3.3 plugin LaTeXTools.getRegion
reloading python 3.3 plugin LaTeXTools.getTeXRoot
reloading python 3.3 plugin LaTeXTools.jumpto_anywhere
reloading python 3.3 plugin LaTeXTools.jumpto_tex_file
reloading python 3.3 plugin LaTeXTools.jumpToPDF
reloading python 3.3 plugin LaTeXTools.kpsewhich
reloading python 3.3 plugin LaTeXTools.latex_cite_completions
reloading python 3.3 plugin LaTeXTools.latex_cwl_completions
reloading python 3.3 plugin LaTeXTools.latex_directive_completions
reloading python 3.3 plugin LaTeXTools.latex_env_completions
reloading python 3.3 plugin LaTeXTools.latex_fill_all
reloading python 3.3 plugin LaTeXTools.latex_glossary_completions
reloading python 3.3 plugin LaTeXTools.latex_input_completions
reloading python 3.3 plugin LaTeXTools.latex_installed_packages
reloading python 3.3 plugin LaTeXTools.latex_own_command_completions
reloading python 3.3 plugin LaTeXTools.latex_ref_completions
reloading python 3.3 plugin LaTeXTools.latexCommand
reloading python 3.3 plugin LaTeXTools.latexDocumentationViewer
reloading python 3.3 plugin LaTeXTools.latexEnvCloser
reloading python 3.3 plugin LaTeXTools.latexEnvironment
reloading python 3.3 plugin LaTeXTools.latextools_cache_listener
reloading python 3.3 plugin LaTeXTools.latextools_default_settings
reloading python 3.3 plugin LaTeXTools.latextools_plugin
reloading python 3.3 plugin LaTeXTools.latextools_sublime_version_listener
reloading python 3.3 plugin LaTeXTools.makePDF
reloading python 3.3 plugin LaTeXTools.migrate
reloading python 3.3 plugin LaTeXTools.open_detexify
reloading python 3.3 plugin LaTeXTools.parseTeXlog
reloading python 3.3 plugin LaTeXTools.search_commands
reloading python 3.3 plugin LaTeXTools.system_check
reloading python 3.3 plugin LaTeXTools.texcount
reloading python 3.3 plugin LaTeXTools.texMacro
reloading python 3.3 plugin LaTeXTools.texSections
reloading python 3.3 plugin LaTeXTools.texSyntaxListener
reloading python 3.3 plugin LaTeXTools.toc_quickpanel
reloading python 3.3 plugin LaTeXTools.toggle_auto
reloading python 3.3 plugin LaTeXTools.toggle_focus
reloading python 3.3 plugin LaTeXTools.toggle_fwdsync
reloading python 3.3 plugin LaTeXTools.toggle_show
reloading python 3.3 plugin LaTeXTools.toggle_view_on_build
reloading python 3.3 plugin SublimeREPL.__init__
reloading python 3.3 plugin SublimeREPL.completions
reloading python 3.3 plugin SublimeREPL.lang_integration
reloading python 3.3 plugin SublimeREPL.run_existing_command
reloading python 3.3 plugin SublimeREPL.sublimerepl
reloading python 3.3 plugin SublimeREPL.sublimerepl_build_system_hack
reloading python 3.3 plugin SublimeREPL.text_transfer
plugins loaded
Loaded LaTeXTools plugins ['pdf_builder'] from path /home/gabriel/.config/sublime-text/Packages/LaTeXTools/builders/pdfBuilder.py
Loaded LaTeXTools plugins ['traditional_builder', 'simple_builder', 'script_builder', 'basic_builder'] from path /home/gabriel/.config/sublime-text/Packages/LaTeXTools/builders
Loading LaTeXTools plugins...
Loaded LaTeXTools plugins ['base_viewer'] from path /home/gabriel/.config/sublime-text/Packages/LaTeXTools/viewers/base_viewer.py
Loaded LaTeXTools plugins ['okular_viewer', 'evince_viewer', 'preview_viewer', 'command_viewer', 'zathura_viewer', 'sumatra_viewer', 'skim_viewer'] from path /home/gabriel/.config/sublime-text/Packages/LaTeXTools/viewers
Loaded LaTeXTools plugins ['new_bibliography', 'traditional_bibliography'] from path /home/gabriel/.config/sublime-text/Packages/LaTeXTools/bibliography_plugins
Loaded LaTeXTools plugins [] from path /home/gabriel/.config/sublime-text/Packages/LaTeXTools/builders/pdfBuilder.py
Loaded LaTeXTools plugins [] from path /home/gabriel/.config/sublime-text/Packages/LaTeXTools/builders
Package Control: No updated packages

The console shows this warning for some actions (not really sure what triggers this):

Package Control: No updated packages
Unable to open /home/gabriel/.config/sublime-text/Packages/LSP-ruff/LSP-ruff.sublime-settings
reloading settings Packages/User/LSP-ruff.sublime-settings

These are the packages installed:

Captura de pantalla de 2023-03-13 09 43 47

I also have python3-venv and python3.10-venv installed.

Is LSP-ruff present in the status field?

Try enabling "log_debug": true LSP setting and checking the ST console after opening the file. I have a feeling the diagnostics are being ignored.

This is what I see with "log_debug": true:

LSP: LSP-ruff: Supported execute commands: ['ruff.applyAutofix', 'ruff.applyOrganizeImports']
LSP: LSP-ruff: supported code action kinds: ['quickfix', 'source.fixAll', 'source.organizeImports', 'source.fixAll.ruff', 'source.organizeImports.ruff']
LSP: ignoring unsuitable diagnostics for file:///home/gabriel/Github/fastmp/fastmp/fastmp.py reason: not inside window folders
LSP: ignoring unsuitable diagnostics for file:///home/gabriel/Dropbox/python-test/230311_113324.py reason: not inside window folders
Package Control: Skipping automatic upgrade, last run at 2023-03-13 09:45:11, next run at 2023-03-13 10:45:11 or after

The weird thing is that that file (fastMP) appears to be the one file where linting does happen:

Captura de pantalla de 2023-03-13 09 51 37

The file is not within folders added to the sidebar so diagnostics are being ignored.

We probably will soon disable this behavior for this package using new option (sublimelsp/LSP#2218)

But the fastMP file is not in the project and it does show linting. Also, for the files where it does seem to work it shows very few warnings. Example (file in project) only one warning is shown where there sould be many:

Captura de pantalla de 2023-03-13 10 48 23

Is there a setting I should modify?

But the fastMP file is not in the project and it does show linting.

I think it is. What are your project folders? You can check by executing window.folders() in the ST console.

Sorry, I was mistaken. The file where it does work is indeed inside the project, fastMP is not and it does not work in it.

What about the very few issues with the code being shown?

Maybe Ruff does not support the violation, see https://beta.ruff.rs/docs/rules/.

Also, Ruff does only annotate code style violations. I recommend installing LSP-pyright alongside LSP-ruff for the best experience.

The violations shown in the screenshot above are all supported. Note for example that the only violation shown is the bb is never used which is fine but aa above is also never used but no linting appears. Also, the lack of spaces, the lack of new lines and the lines too long are not shown as violations and I think they should all be shown

If you would post the code then we could test it on our side.

Also, you can run ruff manually and verify whether it shows the same or not.

Here's an example

import pandas as pd
import numpy as np

"""
"""
56
aa=3+3





#cmmt
path0 = "../some_path" 

data_CG =pd.read_csv(path0)  
def main():  
    # func1()
           #Empty spaces
    func2('val')
    bb =3*4
    sfgdg = yyy

def func1():
    """no empty line after this line"""

The number 56 is just sitting there, variable aa is not used but not flagged, there are many empty lines, comments with no spaces, trailing spaces, functions not used, ... This is what is being flagged:

Captura de pantalla de 2023-03-13 12 53 19

Running ruff check ruff_test.py manually in the terminal flags the same issues and no more

The number 56 is just sitting there

Nothing technically wrong with that

variable aa is not used but not flagged
functions not used

it shouldn't be flagged because variables in global scope can be imported from the outside so this in many cases is expected (unless you define __all__).

there are many empty lines

ruff doesn't yet implement rules that detect multiple empty lines

All in all, it appears to work as expected and the problem is with your expectations. :)

Feel free to report any issues specific to ruff in its repo and not here since we don't control its behavior.

Also there is a playground for testing ruff manually at https://play.ruff.rs/

Thank you!