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

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

Open
JCZuurmond opened this issue Jan 17, 2025 · 0 comments
Labels
internal this pull request won't appear in release notes migrate/python Pull requests that update Python code python Pull requests that update Python code

Comments

@JCZuurmond
Copy link
Member

JCZuurmond commented Jan 17, 2025

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

@JCZuurmond JCZuurmond added internal this pull request won't appear in release notes migrate/python Pull requests that update Python code python Pull requests that update Python code labels Jan 17, 2025
@github-project-automation github-project-automation bot moved this to Todo in UCX Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal this pull request won't appear in release notes migrate/python Pull requests that update Python code python Pull requests that update Python code
Projects
Status: Todo
Development

No branches or pull requests

1 participant