@@ -358,14 +358,18 @@ def validate(
358358 syntax_valid , syntax_errors = self ._check_syntax (sql )
359359 if not syntax_valid :
360360 errors .extend (syntax_errors )
361- self ._record_validation_metrics (database_id , ValidationStatus .INVALID_SYNTAX )
361+ self ._record_validation_metrics (
362+ database_id , ValidationStatus .INVALID_SYNTAX
363+ )
362364 return ValidationStatus .INVALID_SYNTAX , errors
363365
364366 # Security check
365367 is_safe , security_errors = self ._check_security (sql )
366368 if not is_safe :
367369 errors .extend (security_errors )
368- self ._record_validation_metrics (database_id , ValidationStatus .DANGEROUS_QUERY )
370+ self ._record_validation_metrics (
371+ database_id , ValidationStatus .DANGEROUS_QUERY
372+ )
369373 return ValidationStatus .DANGEROUS_QUERY , errors
370374
371375 # Schema alignment check
@@ -392,7 +396,9 @@ def _record_validation_metrics(
392396 valid = status == ValidationStatus .VALID ,
393397 )
394398 if status == ValidationStatus .INVALID_SYNTAX :
395- metrics .record_sql_syntax_error (database_id = database_id , error_type = "syntax" )
399+ metrics .record_sql_syntax_error (
400+ database_id = database_id , error_type = "syntax"
401+ )
396402
397403 def _check_syntax (self , sql : str ) -> tuple [bool , list [str ]]:
398404 """Check basic SQL syntax."""
@@ -801,11 +807,7 @@ async def generate_sql(
801807 if show_reasoning :
802808 reasoning_trace [- 1 ].observation = "SQL validation passed"
803809
804- if (
805- self ._enable_validation
806- and valid_syntax
807- and inference_result .sql
808- ):
810+ if self ._enable_validation and valid_syntax and inference_result .sql :
809811 semantic_feedback = self ._validator .check_semantics (
810812 natural_query = natural_query ,
811813 sql = inference_result .sql ,
@@ -1066,10 +1068,9 @@ def _build_prompt_cache_key(
10661068 "use_default_examples" : use_default_examples ,
10671069 }
10681070
1069- return (
1070- hashlib .sha256 (json .dumps (key_data , sort_keys = True ).encode ())
1071- .hexdigest ()[:32 ]
1072- )
1071+ return hashlib .sha256 (
1072+ json .dumps (key_data , sort_keys = True ).encode ()
1073+ ).hexdigest ()[:32 ]
10731074
10741075 async def _generate_with_retry (
10751076 self ,
0 commit comments