python-lsp / python-lsp-server

Fork of the python-language-server project, maintained by the Spyder IDE team and the community
MIT License
1.75k stars 187 forks source link

disable all parsing and linting / make a code segment "invisible" to the server #522

Closed jerabaul29 closed 3 months ago

jerabaul29 commented 5 months ago

Hi :)

Many thanks for an awesome project.

Is there a way (if so can you point to this, as I searched a bit but did not find it) / if not could the following functionality be added:

For example, I have a setting in which some ipython magics are in my .py file, and I would like to ignore these altogether from the lsp parser and linter point of view:

Screenshot from 2024-01-26 12-50-01

Any way to get this to work, i.e. to not send these lines to the lsp / ask the lsp to ignore them altogether / catch and discard all lsp feedback on these lines? :)

ccordoba12 commented 3 months ago

Hey @jerabaul29, thanks for reporting. That depends on the linter you're using (i.e. flake8, ruff, pylint, etc). For pylint it involves doing what you already did, but it seems you have another linter enabled.

For flake8 (and I guess for ruff too), you need to add an inline comment at the end of the line you want to skip from the linter like this

%reset -f  # noqa