diff --git a/spectacles/exceptions.py b/spectacles/exceptions.py index baef9fbc..e2577dd0 100644 --- a/spectacles/exceptions.py +++ b/spectacles/exceptions.py @@ -99,7 +99,7 @@ def __init__( field_name: str, message: str, severity: str, - lookml_url: str, + lookml_url: Optional[str], file_path: Optional[str], line_number: Optional[int] = None, ): diff --git a/spectacles/validators/lookml.py b/spectacles/validators/lookml.py index 37910300..60313fae 100644 --- a/spectacles/validators/lookml.py +++ b/spectacles/validators/lookml.py @@ -1,4 +1,4 @@ -from typing import Dict, Any +from typing import Dict, Any, Optional from spectacles.client import LookerClient from spectacles.exceptions import LookMLError @@ -25,6 +25,7 @@ def validate(self, project: str, severity: str = "warning") -> Dict[str, Any]: severity_level = NAME_TO_LEVEL[severity] validation_results = self.client.lookml_validation(project) errors = [] + lookml_url: Optional[str] = None for error in validation_results["errors"]: if error["file_path"]: lookml_url = ( @@ -36,8 +37,6 @@ def validate(self, project: str, severity: str = "warning") -> Dict[str, Any]: ) if error["line_number"]: lookml_url += "?line=" + str(error["line_number"]) - else: - lookml_url = None lookml_error = LookMLError( model=error["model_id"],