Skip to content

Commit 04dbd5f

Browse files
Import typeddict from typing_extentions (#104)
* import typeddict from typing_extentions * Add typing-extensions * Move shim logic to one file. * typo * simpilfy * order --------- Co-authored-by: Mark Daoust <[email protected]>
1 parent a1e4e16 commit 04dbd5f

File tree

6 files changed

+22
-9
lines changed

6 files changed

+22
-9
lines changed

google/generativeai/types/citation_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
from __future__ import annotations
16+
from typing import List
1617

17-
from typing import Optional, List
18+
from typing_extensions import TypedDict
1819

1920
from google.ai import generativelanguage as glm
2021
from google.generativeai import string_utils
2122

22-
from typing import TypedDict
2323

2424
__all__ = [
2525
"CitationMetadataDict",

google/generativeai/types/discuss_types.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@
1616

1717
import abc
1818
import dataclasses
19-
from typing import Any, Dict, TypedDict, Union, Iterable, Optional, Tuple, List
19+
from typing import Any, Dict, Union, Iterable, Optional, Tuple, List
20+
from typing_extensions import TypedDict
2021

2122
import google.ai.generativelanguage as glm
2223
from google.generativeai import string_utils
2324

2425
from google.generativeai.types import safety_types
2526
from google.generativeai.types import citation_types
2627

28+
2729
__all__ = [
2830
"MessageDict",
2931
"MessageOptions",

google/generativeai/types/model_types.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,16 @@
2222
import json
2323
import pathlib
2424
import re
25-
from typing import Any, Iterable, TypedDict, Union
25+
26+
from typing import Any, Iterable, Union
27+
2628
import urllib.request
29+
from typing_extensions import TypedDict
2730

2831
import google.ai.generativelanguage as glm
2932
from google.generativeai import string_utils
3033

34+
3135
__all__ = [
3236
"Model",
3337
"ModelNameOptions",
@@ -266,12 +270,12 @@ def _convert_dict(data, input_key, output_key):
266270

267271
try:
268272
inputs = data[input_key]
269-
except KeyError as e:
273+
except KeyError:
270274
raise KeyError(f'input_key is "{input_key}", but data has keys: {sorted(data.keys())}')
271275

272276
try:
273277
outputs = data[output_key]
274-
except KeyError as e:
278+
except KeyError:
275279
raise KeyError(f'output_key is "{output_key}", but data has keys: {sorted(data.keys())}')
276280

277281
for i, o in zip(inputs, outputs):

google/generativeai/types/safety_types.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22

33
from collections.abc import Mapping
44

5+
import typing
6+
from typing import Dict, Iterable, List, Union
7+
8+
from typing_extensions import TypedDict
9+
10+
511
from google.ai import generativelanguage as glm
612
from google.generativeai import string_utils
713

8-
import typing
9-
from typing import Iterable, Dict, Iterable, List, TypedDict, Union
1014

1115
__all__ = [
1216
"HarmCategory",

google/generativeai/types/text_types.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
# limitations under the License.
1515
from __future__ import annotations
1616

17+
import sys
1718
import abc
1819
import dataclasses
19-
from typing import Any, Dict, List, TypedDict
20+
from typing import Any, Dict, List
21+
from typing_extensions import TypedDict
2022

2123
from google.generativeai import string_utils
2224
from google.generativeai.types import safety_types

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def get_version():
4646
"google-ai-generativelanguage==0.4.0",
4747
"google-auth",
4848
"google-api-core",
49+
"typing-extensions",
4950
"protobuf",
5051
"tqdm",
5152
]

0 commit comments

Comments
 (0)