Skip to content

Can't set ignored error codes #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
astoff opened this issue Feb 28, 2023 · 7 comments · Fixed by #20
Closed

Can't set ignored error codes #19

astoff opened this issue Feb 28, 2023 · 7 comments · Fixed by #20

Comments

@astoff
Copy link

astoff commented Feb 28, 2023

I'm sending the following configuration to pylsp via the didChangeConfiguration notification but I don't get the desired effect of disabling error code D101:

{
  "pylsp": {
    "plugins": {
      "pycodestyle": {
        "enabled": false
      },
      "pyflakes": {
        "enabled": false
      },
      "ruff": {
        "enabled": true,
        "ignore": [
          "D101"
        ]
      }
    }
  }
}

However, if I switch pylsp.ruff.enabled to false, the plugin is disabled, so the editor part of my setup must be working.

@jhossbach
Copy link
Member

jhossbach commented Feb 28, 2023

Please enable debug messages for pylsp and post the log messages here, i.e. by starting pylsp with pylsp -vvv --log-file /tmp/lsp.log

@jhossbach
Copy link
Member

Thx for the log @astoff. This is the relevant line:

2023-02-28 11:58:43,096 CET - DEBUG - pylsp_ruff.ruff_lint - Got ruff settings: {'extendSelect': None, 'enabled': True, 'ignore': ['D101'], 'perFileIgnores': None, 'lineLength': None, 'exclude': None, 'executable': 'ruff', 'select': None, 'config': None}
2023-02-28 11:58:43,097 CET - DEBUG - pylsp_ruff.ruff_lint - Found pyproject file: /.../pyproject.toml, skipping pylsp config.

This was intentionally set in order to leave any configuration to be found by ruff itself.
There are two options here:

  • You can add D101 to your ignore/extend-ignore list in the pyproject.toml file. If you are not the only one working on this project this would be advantageous in that it is editor-independent. However if you only want it specifically for your editor option two might be relevant:
  • We add a config entry called ignore-extended and make it independent of any pyproject.toml file present. I am reluctant to add the latter functionality as this would likely lead to confusing behaviour

@astoff
Copy link
Author

astoff commented Mar 1, 2023

Thanks for looking into this. Indeed, I don't want to change the pyproject.toml file, and my intention was to apply some extra settings on top of it.

Let me explain a bit my workflow. The pyproject.toml file has all the nitty-gritty rules checked by CI and that need to be fulfilled before my code is ready to merge. I can also run them locally with make lint when I'm polishing up my work. On the other hand, when I'm actually coding things up, I don't want to get nagged by details; I only want to see the diagnostics that help me write the code.

I'm not sure which confusing behavior you foresee, but it seems very natural and customary to me that server settings > project settings > system settings get merged, with that order of precedence.

@jhossbach
Copy link
Member

I had the same issue once. How about we include any extendIgnore and extendSelect options regardless of config files present?

@astoff
Copy link
Author

astoff commented Mar 1, 2023

That would work for me, yes. :-)

jhossbach added a commit that referenced this issue Mar 1, 2023
Also allow use of server options over project settings
jhossbach added a commit that referenced this issue Mar 1, 2023
Also allow use of server options over project settings
@jhossbach
Copy link
Member

Pushed and tested, please try on your side.

@astoff
Copy link
Author

astoff commented Mar 1, 2023

I just tested here and it works fine so far. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants