Skip to content

Commit b65e579

Browse files
authored
Patch: improve type hint (langchain-ai#15451)
1 parent 8ebf55e commit b65e579

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

libs/community/langchain_community/utilities/sql_database.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from __future__ import annotations
33

44
import warnings
5-
from typing import Any, Dict, Iterable, List, Literal, Optional, Sequence, Union
5+
from typing import Any, Dict, Iterable, List, Literal, Optional, Sequence
66

77
import sqlalchemy
88
from langchain_core.utils import get_from_env
@@ -376,14 +376,14 @@ def _get_sample_rows(self, table: Table) -> str:
376376
def _execute(
377377
self,
378378
command: str,
379-
fetch: Union[Literal["all"], Literal["one"]] = "all",
379+
fetch: Literal["all", "one"] = "all",
380380
) -> Sequence[Dict[str, Any]]:
381381
"""
382382
Executes SQL command through underlying engine.
383383
384384
If the statement returns no rows, an empty list is returned.
385385
"""
386-
with self._engine.begin() as connection:
386+
with self._engine.begin() as connection: # type: Connection
387387
if self._schema is not None:
388388
if self.dialect == "snowflake":
389389
connection.exec_driver_sql(
@@ -426,7 +426,7 @@ def _execute(
426426
def run(
427427
self,
428428
command: str,
429-
fetch: Union[Literal["all"], Literal["one"]] = "all",
429+
fetch: Literal["all", "one"] = "all",
430430
include_columns: bool = False,
431431
) -> str:
432432
"""Execute a SQL command and return a string representing the results.
@@ -471,7 +471,7 @@ def get_table_info_no_throw(self, table_names: Optional[List[str]] = None) -> st
471471
def run_no_throw(
472472
self,
473473
command: str,
474-
fetch: Union[Literal["all"], Literal["one"]] = "all",
474+
fetch: Literal["all", "one"] = "all",
475475
include_columns: bool = False,
476476
) -> str:
477477
"""Execute a SQL command and return a string representing the results.

libs/core/langchain_core/prompts/few_shot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def is_lc_serializable(cls) -> bool:
9898
prefix: str = ""
9999
"""A prompt template string to put before the examples."""
100100

101-
template_format: Union[Literal["f-string"], Literal["jinja2"]] = "f-string"
101+
template_format: Literal["f-string", "jinja2"] = "f-string"
102102
"""The format of the prompt template. Options are: 'f-string', 'jinja2'."""
103103

104104
@root_validator()

libs/core/langchain_core/prompts/prompt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def get_lc_namespace(cls) -> List[str]:
6565
template: str
6666
"""The prompt template."""
6767

68-
template_format: Union[Literal["f-string"], Literal["jinja2"]] = "f-string"
68+
template_format: Literal["f-string", "jinja2"] = "f-string"
6969
"""The format of the prompt template. Options are: 'f-string', 'jinja2'."""
7070

7171
validate_template: bool = False

0 commit comments

Comments
 (0)