mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
fix: docstring concatenation in 3.13
The issue was caused by a breaking change in Python 3.13's inspect.cleandoc() function that made it more conservative about whitespace handling:
Root Cause:
- Python 3.12-: inspect.cleandoc() used line.lstrip() - strips all whitespace (spaces, tabs, etc.)
- Python 3.13+: inspect.cleandoc() uses line.lstrip(' ') - strips only space characters
PiperOrigin-RevId: 793921360
This commit is contained in:
committed by
Copybara-Service
parent
e295feb4c6
commit
88f759a941
@@ -16,6 +16,8 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import functools
|
import functools
|
||||||
import json
|
import json
|
||||||
|
import sys
|
||||||
|
import textwrap
|
||||||
import types
|
import types
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
@@ -494,8 +496,17 @@ def get_execute_sql(config: BigQueryToolConfig) -> Callable[..., dict]:
|
|||||||
|
|
||||||
# Now, set the new docstring
|
# Now, set the new docstring
|
||||||
if config.write_mode == WriteMode.PROTECTED:
|
if config.write_mode == WriteMode.PROTECTED:
|
||||||
execute_sql_wrapper.__doc__ += _execute_sql_protecetd_write_examples
|
examples = _execute_sql_protecetd_write_examples
|
||||||
else:
|
else:
|
||||||
execute_sql_wrapper.__doc__ += _execute_sql_write_examples
|
examples = _execute_sql_write_examples
|
||||||
|
|
||||||
|
# Handle Python 3.13+ inspect.cleandoc behavior change
|
||||||
|
# Python 3.13 changed inspect.cleandoc from lstrip() to lstrip(' '), making it
|
||||||
|
# more conservative. The appended examples have inconsistent indentation that
|
||||||
|
# Python 3.11/3.12's aggressive cleandoc would fix, but 3.13+ needs help.
|
||||||
|
if sys.version_info >= (3, 13):
|
||||||
|
examples = textwrap.dedent(examples)
|
||||||
|
|
||||||
|
execute_sql_wrapper.__doc__ += examples
|
||||||
|
|
||||||
return execute_sql_wrapper
|
return execute_sql_wrapper
|
||||||
|
|||||||
Reference in New Issue
Block a user