2121from typing import (
2222 TYPE_CHECKING ,
2323 ForwardRef ,
24- Generic ,
2524 Optional ,
26- TypeVar ,
2725 get_args ,
2826)
2927from urllib .parse import quote , urljoin
6563
6664SETTINGS = MAPIClientSettings () # type: ignore
6765
68- T = TypeVar ("T" )
6966
70-
71- class BaseRester (Generic [T ]):
67+ class BaseRester :
7268 """Base client class with core stubs."""
7369
7470 suffix : str = ""
@@ -140,15 +136,8 @@ def __init__(
140136 if not self .endpoint .endswith ("/" ):
141137 self .endpoint += "/"
142138
143- if session :
144- self ._session = session
145- else :
146- self ._session = None # type: ignore
147-
148- if s3_client :
149- self ._s3_client = s3_client
150- else :
151- self ._s3_client = None
139+ self ._session = session
140+ self ._s3_client = s3_client
152141
153142 @property
154143 def session (self ) -> requests .Session :
@@ -596,7 +585,7 @@ def _submit_requests( # noqa
596585 url: url used to make request
597586 use_document_model: if None, will defer to the self.use_document_model attribute
598587 parallel_param: parameter to parallelize requests with
599- num_chu: fieldsnky : Maximum number of chunks of data to yield. None will yield all possible.
588+ num_chunks : Maximum number of chunks of data to yield. None will yield all possible.
600589 chunk_size: Number of data entries per chunk.
601590 timeout: Time in seconds to wait until a request timeout error is thrown
602591
@@ -1077,7 +1066,9 @@ def _generate_returned_model(
10771066 include_fields : dict [str , tuple [type , FieldInfo ]] = {}
10781067 for name in set_fields :
10791068 field_copy = model_fields [name ]._copy ()
1080- field_copy .default = None
1069+ if not field_copy .default_factory :
1070+ # Fields with a default_factory cannot also have a default in pydantic>=2.12.3
1071+ field_copy .default = None
10811072 include_fields [name ] = (
10821073 Optional [model_fields [name ].annotation ],
10831074 field_copy ,
@@ -1097,8 +1088,6 @@ def _generate_returned_model(
10971088 ),
10981089 __module__ = self .document_model .__module__ ,
10991090 )
1100- # if other_vars:
1101- # data_model.model_rebuild(_types_namespace=other_vars)
11021091
11031092 orig_rester_name = self .document_model .__name__
11041093
@@ -1151,7 +1140,7 @@ def _query_resource_data(
11511140 suburl : str | None = None ,
11521141 use_document_model : bool | None = None ,
11531142 timeout : int | None = None ,
1154- ) -> list [T ] | list [dict ]:
1143+ ) -> list [BaseModel ] | list [dict ]:
11551144 """Query the endpoint for a list of documents without associated meta information. Only
11561145 returns a single page of results.
11571146
@@ -1181,7 +1170,7 @@ def _search(
11811170 all_fields : bool = True ,
11821171 fields : list [str ] | None = None ,
11831172 ** kwargs ,
1184- ) -> list [T ] | list [dict ]:
1173+ ) -> list [BaseModel ] | list [dict ]:
11851174 """A generic search method to retrieve documents matching specific parameters.
11861175
11871176 Arguments:
@@ -1216,7 +1205,7 @@ def get_data_by_id(
12161205 self ,
12171206 document_id : str ,
12181207 fields : list [str ] | None = None ,
1219- ) -> T | dict :
1208+ ) -> BaseModel | dict :
12201209 warnings .warn (
12211210 "get_data_by_id is deprecated and will be removed soon. Please use the search method instead." ,
12221211 DeprecationWarning ,
@@ -1251,7 +1240,7 @@ def _get_all_documents(
12511240 fields = None ,
12521241 chunk_size = 1000 ,
12531242 num_chunks = None ,
1254- ) -> list [T ] | list [dict ]:
1243+ ) -> list [BaseModel ] | list [dict ]:
12551244 """Iterates over pages until all documents are retrieved. Displays
12561245 progress using tqdm. This method is designed to give a common
12571246 implementation for the search_* methods on various endpoints. See
0 commit comments