Skip to content
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

Allow overriding severity based on error code prefix match #195

Closed
jnooree opened this issue Aug 2, 2023 · 2 comments
Closed

Allow overriding severity based on error code prefix match #195

jnooree opened this issue Aug 2, 2023 · 2 comments

Comments

@jnooree
Copy link
Contributor

jnooree commented Aug 2, 2023

Pycodestyle error codes (which are reported by flake8) are grouped by prefix: E1xx for indentation, E2xx for whitespaces, etc.
Currently, this extension could override flake8 severity only if full error code matches. It would be great to specify such "prefix" in config, and override all matching error codes at once. This also matches the behavior of flake8 itself.

For example, the following config:

{
    "flake8.severity": {
        "E": "Warning",
        "E1": "Information",
    }
}

Will report all Exxx errors as warnings, and all indentation related errors (E1xx) as information.

@karthiknadig
Copy link
Member

Duplicate of #7

See #7 for more details on this.

@karthiknadig karthiknadig closed this as not planned Won't fix, can't repro, duplicate, stale Aug 2, 2023
@karthiknadig
Copy link
Member

karthiknadig commented Aug 2, 2023

@jnooree The code for this can be found here:

def _get_severity(
code: str, code_type: str, severity: Dict[str, str]
) -> lsp.DiagnosticSeverity:
"""Converts severity provided by linter to LSP specific value."""
value = severity.get(code, None) or severity.get(code_type, "Error")
try:
return lsp.DiagnosticSeverity[value]
except KeyError:
pass
return lsp.DiagnosticSeverity.Error

The severity setting contents are passed into this function as a dictionary.

We are open to accept PRs on this :)

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

No branches or pull requests

2 participants