Skip to content

[TECH DEBT] Let LinterContext.linter return None if no linter is found instead of raising a ValueError #3544

Open
@JCZuurmond

Description

@JCZuurmond

Description

Let LinterContext.linter return None if no linter is found instead of raising a ValueError:

def linter(self, language: Language) -> Linter:
if language not in self._linters:
raise ValueError(f"Unsupported language: {language}")
if language is Language.PYTHON:
return PythonSequentialLinter(cast(list[PythonLinter], self._linters[language]), [], [])
if language is Language.SQL:
return SqlSequentialLinter(cast(list[SqlLinter], self._linters[language]), [], [])
raise ValueError(f"Unsupported language: {language}")

Motivation

For a more graceful way handling of a linter not being found, now we are unsure if the last ValueError will be raised in case someone adds a new linter for a new language but forgets to update the if condition there

Metadata

Metadata

Assignees

No one assigned

    Labels

    internalthis pull request won't appear in release notesmigrate/pythonPull requests that update Python codepythonPull requests that update Python code

    Type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions