Skip to content

Commit 6a77a31

Browse files
author
Andrew Omondi
committed
chore: replace typing.List with list
1 parent 78c327c commit 6a77a31

34 files changed

Lines changed: 148 additions & 154 deletions

packages/abstractions/kiota_abstractions/authentication/allowed_hosts_validator.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List, Set
1+
from typing import Set
22
from urllib.parse import urlparse
33

44

@@ -7,31 +7,31 @@ class AllowedHostsValidator:
77
a host is valid before authenticating a request
88
"""
99

10-
def __init__(self, allowed_hosts: List[str]) -> None:
10+
def __init__(self, allowed_hosts: list[str]) -> None:
1111
"""Creates a new AllowedHostsValidator object with provided values.
1212
1313
Args:
14-
allowed_hosts (List[str]): A list of valid hosts. If the list is empty, all hosts
14+
allowed_hosts (list[str]): A list of valid hosts. If the list is empty, all hosts
1515
are valid.
1616
"""
1717
if not isinstance(allowed_hosts, list):
1818
raise TypeError("Allowed hosts must be a list of strings")
1919

2020
self.allowed_hosts: Set[str] = {x.lower() for x in allowed_hosts}
2121

22-
def get_allowed_hosts(self) -> List[str]:
22+
def get_allowed_hosts(self) -> list[str]:
2323
"""Gets the list of valid hosts. If the list is empty, all hosts are valid.
2424
2525
Returns:
26-
List[str]: A list of valid hosts. If the list is empty, all hosts are valid.
26+
list[str]: A list of valid hosts. If the list is empty, all hosts are valid.
2727
"""
2828
return list(self.allowed_hosts)
2929

30-
def set_allowed_hosts(self, allowed_hosts: List[str]) -> None:
30+
def set_allowed_hosts(self, allowed_hosts: list[str]) -> None:
3131
"""Sets the list of valid hosts. If the list is empty, all hosts are valid.
3232
3333
Args:
34-
allowed_hosts (List[str]): A list of valid hosts. If the list is empty, all hosts
34+
allowed_hosts (list[str]): A list of valid hosts. If the list is empty, all hosts
3535
are valid
3636
"""
3737
if not isinstance(allowed_hosts, list):

packages/abstractions/kiota_abstractions/authentication/api_key_authentication_provider.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# ------------------------------------------------------------------------------
66

77
from enum import Enum
8-
from typing import Any, List
8+
from typing import Any
99
from urllib.parse import parse_qsl, urlencode, urlparse, urlunparse
1010

1111
from kiota_abstractions.request_information import RequestInformation
@@ -33,7 +33,7 @@ def __init__(
3333
key_location: KeyLocation,
3434
api_key: str,
3535
parameter_name: str,
36-
allowed_hosts: List[str] = [],
36+
allowed_hosts: list[str] = [],
3737
) -> None:
3838
if not isinstance(key_location, KeyLocation):
3939
err = "key_location can only be 'query_parameter' or 'header'"

packages/abstractions/kiota_abstractions/base_request_configuration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# See License in the project root for license information.
55
# ------------------------------------
66
from dataclasses import dataclass
7-
from typing import Generic, List, Optional, TypeVar
7+
from typing import Generic, Optional, TypeVar
88
from warnings import warn
99

1010
from .headers_collection import HeadersCollection
@@ -21,7 +21,7 @@ class RequestConfiguration(Generic[QueryParameters]):
2121
# Request headers
2222
headers: HeadersCollection = HeadersCollection()
2323
# Request options
24-
options: Optional[List[RequestOption]] = None
24+
options: Optional[list[RequestOption]] = None
2525
# Request query parameters
2626
query_parameters: Optional[QueryParameters] = None
2727

packages/abstractions/kiota_abstractions/default_query_parameters.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# See License in the project root for license information.
55
# ------------------------------------
66
from dataclasses import dataclass
7-
from typing import List, Optional
87
from warnings import warn
98

109

packages/abstractions/kiota_abstractions/headers_collection.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import List, Set, Union
3+
from typing import Set, Union
44

55

66
class HeadersCollection():
@@ -84,12 +84,12 @@ def add_all(self, headers: HeadersCollection) -> None:
8484
for value in values:
8585
self.add(key, value)
8686

87-
def add(self, header_name: str, header_values: Union[str, List[str]]) -> None:
87+
def add(self, header_name: str, header_values: Union[str, list[str]]) -> None:
8888
"""Adds values to the header with the specified name.
8989
9090
Args:
9191
header_name (str): The name of the header to add values to.
92-
header_values (List[str]): The values to add to the header.
92+
header_values (list[str]): The values to add to the header.
9393
"""
9494
if not header_name:
9595
raise ValueError("Header name cannot be null")
@@ -112,10 +112,10 @@ def add(self, header_name: str, header_values: Union[str, List[str]]) -> None:
112112
else:
113113
self._headers[header_name] = {header_values}
114114

115-
def keys(self) -> List[str]:
115+
def keys(self) -> list[str]:
116116
"""Gets the header names present in the collection.
117117
Returns:
118-
List[str]: The header names present in the collection.
118+
list[str]: The header names present in the collection.
119119
"""
120120
return list(self._headers.keys())
121121

packages/abstractions/kiota_abstractions/request_adapter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from abc import ABC, abstractmethod
33
from datetime import date, datetime, time, timedelta
44
from io import BytesIO
5-
from typing import Generic, List, Optional, TypeVar, Union
5+
from typing import Generic, Optional, TypeVar, Union
66
from uuid import UUID
77

88
from .request_information import RequestInformation
@@ -59,7 +59,7 @@ async def send_collection_async(
5959
request_info: RequestInformation,
6060
parsable_factory: ParsableFactory[ModelType],
6161
error_map: Optional[dict[str, type[ParsableFactory]]],
62-
) -> Optional[List[ModelType]]:
62+
) -> Optional[list[ModelType]]:
6363
"""Excutes the HTTP request specified by the given RequestInformation and returns the
6464
deserialized response model collection.
6565
@@ -81,7 +81,7 @@ async def send_collection_of_primitive_async(
8181
request_info: RequestInformation,
8282
response_type: type[PrimitiveType],
8383
error_map: Optional[dict[str, type[ParsableFactory]]],
84-
) -> Optional[List[PrimitiveType]]:
84+
) -> Optional[list[PrimitiveType]]:
8585
"""Excutes the HTTP request specified by the given RequestInformation and returns the
8686
deserialized response model collection.
8787
@@ -93,7 +93,7 @@ async def send_collection_of_primitive_async(
9393
case of a failed request.
9494
9595
Returns:
96-
Optional[List[PrimitiveType]]: The deserialized primitive collection.
96+
Optional[list[PrimitiveType]]: The deserialized primitive collection.
9797
"""
9898
pass
9999

packages/abstractions/kiota_abstractions/request_information.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from datetime import date, datetime, time, timedelta, timezone
1010
from enum import Enum
1111
from io import BytesIO
12-
from typing import TYPE_CHECKING, Any, Callable, List, Optional, Set, TypeVar, Union
12+
from typing import TYPE_CHECKING, Any, Callable, Optional, TypeVar, Union
1313
from urllib.parse import unquote
1414
from uuid import UUID
1515

@@ -140,13 +140,13 @@ def request_options(self) -> dict[str, RequestOption]:
140140
"""Gets the request options for the request."""
141141
return self.__request_options
142142

143-
def add_request_options(self, options: Optional[List[RequestOption]]) -> None:
143+
def add_request_options(self, options: Optional[list[RequestOption]]) -> None:
144144
if not options:
145145
return
146146
for option in options:
147147
self.__request_options[option.get_key()] = option
148148

149-
def remove_request_options(self, options: List[RequestOption]) -> None:
149+
def remove_request_options(self, options: list[RequestOption]) -> None:
150150
if not options:
151151
return
152152
for option in options:
@@ -156,15 +156,15 @@ def set_content_from_parsable(
156156
self,
157157
request_adapter: RequestAdapter,
158158
content_type: str,
159-
values: Union[U, List[U]],
159+
values: Union[U, list[U]],
160160
) -> None:
161161
"""Sets the request body from a model with the specified content type.
162162
163163
Args:
164164
request_adapter (Optional[RequestAdapter]): The adapter service to get the serialization
165165
writer from.
166166
content_type (Optional[str]): the content type.
167-
values (Union[U, List[U]]): the models.
167+
values (Union[U, list[U]]): the models.
168168
"""
169169
with tracer.start_as_current_span(
170170
self._create_parent_span_name("set_content_from_parsable")
@@ -186,15 +186,15 @@ def set_content_from_scalar(
186186
self,
187187
request_adapter: Optional["RequestAdapter"],
188188
content_type: Optional[str],
189-
values: Union[T, List[T]],
189+
values: Union[T, list[T]],
190190
) -> None:
191191
"""Sets the request body from a scalar value with the specified content type.
192192
193193
Args:
194194
request_adapter (Optional[RequestAdapter]): The adapter service to get the serialization
195195
writer from.
196196
content_type (Optional[str]): the content type to set.
197-
values (Union[T, List[T]]): the scalar values to serialize
197+
values (Union[T, list[T]]): the scalar values to serialize
198198
"""
199199
with tracer.start_as_current_span(
200200
self._create_parent_span_name("set_content_from_scalar")

packages/abstractions/kiota_abstractions/serialization/parse_node.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from abc import ABC, abstractmethod
44
from datetime import date, datetime, time, timedelta
55
from enum import Enum
6-
from typing import TYPE_CHECKING, Callable, List, Optional, TypeVar
6+
from typing import TYPE_CHECKING, Callable, Optional, TypeVar
77
from uuid import UUID
88

99
from .parsable import Parsable
@@ -118,31 +118,31 @@ def get_time_value(self) -> Optional[time]:
118118
pass
119119

120120
@abstractmethod
121-
def get_collection_of_primitive_values(self, primitive_type: type[T]) -> Optional[List[T]]:
121+
def get_collection_of_primitive_values(self, primitive_type: type[T]) -> Optional[list[T]]:
122122
"""Gets the collection of primitive values of the node
123123
Args:
124124
primitive_type: The type of primitive to return.
125125
Returns:
126-
List[T]: The collection of primitive values
126+
list[T]: The collection of primitive values
127127
"""
128128
pass
129129

130130
@abstractmethod
131-
def get_collection_of_object_values(self, factory: ParsableFactory[U]) -> Optional[List[U]]:
131+
def get_collection_of_object_values(self, factory: ParsableFactory[U]) -> Optional[list[U]]:
132132
"""Gets the collection of model object values of the node
133133
Args:
134134
factory (ParsableFactory): The factory to use to create the model object.
135135
Returns:
136-
List[U]: The collection of model object values of the node
136+
list[U]: The collection of model object values of the node
137137
"""
138138
pass
139139

140140
@abstractmethod
141-
def get_collection_of_enum_values(self, enum_class: K) -> Optional[List[K]]:
141+
def get_collection_of_enum_values(self, enum_class: K) -> Optional[list[K]]:
142142
"""Gets the collection of enum values of the node
143143
144144
Returns:
145-
List[K]: The collection of enum values
145+
list[K]: The collection of enum values
146146
"""
147147
pass
148148

packages/abstractions/kiota_abstractions/serialization/serialization_writer.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from abc import ABC, abstractmethod
44
from datetime import date, datetime, time, timedelta
55
from enum import Enum
6-
from typing import Any, Callable, List, Optional, TypeVar
6+
from typing import Any, Callable, Optional, TypeVar
77
from uuid import UUID
88

99
from .parsable import Parsable
@@ -109,39 +109,39 @@ def write_time_value(self, key: Optional[str], value: Optional[time]) -> None:
109109

110110
@abstractmethod
111111
def write_collection_of_primitive_values(
112-
self, key: Optional[str], values: Optional[List[T]]
112+
self, key: Optional[str], values: Optional[list[T]]
113113
) -> None:
114114
"""Writes the specified collection of primitive values to the stream with an optional
115115
given key.
116116
117117
Args:
118118
key (Optional[str]): The key to be used for the written value. May be null.
119-
values (Optional[List[T]]): The collection of primitive values to be written.
119+
values (Optional[list[T]]): The collection of primitive values to be written.
120120
"""
121121
pass
122122

123123
@abstractmethod
124124
def write_collection_of_object_values(
125-
self, key: Optional[str], values: Optional[List[U]]
125+
self, key: Optional[str], values: Optional[list[U]]
126126
) -> None:
127127
"""Writes the specified collection of model objects to the stream with an optional
128128
given key.
129129
130130
Args:
131131
key (Optional[str]): The key to be used for the written value. May be null.
132-
values (Optional[List[U]]): The collection of model objects to be written.
132+
values (Optional[list[U]]): The collection of model objects to be written.
133133
"""
134134
pass
135135

136136
@abstractmethod
137137
def write_collection_of_enum_values(
138-
self, key: Optional[str], values: Optional[List[K]]
138+
self, key: Optional[str], values: Optional[list[K]]
139139
) -> None:
140140
"""Writes the specified collection of enum values to the stream with an optional given key.
141141
142142
Args:
143143
key (Optional[str]): The key to be used for the written value. May be null.
144-
values Optional[List[K]): The enum values to be written.
144+
values Optional[list[K]): The enum values to be written.
145145
"""
146146
pass
147147

@@ -165,7 +165,7 @@ def write_object_value(
165165
Args:
166166
key (Optional[str]): The key to be used for the written value. May be null.
167167
value (Parsable): The model object to be written.
168-
additional_values_to_merge (List[Parsable]): The additional values to merge to the
168+
additional_values_to_merge (list[Parsable]): The additional values to merge to the
169169
main value when serializing an intersection wrapper.
170170
"""
171171
pass

packages/abstractions/kiota_abstractions/store/backing_store.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# ------------------------------------------------------------------------------
66

77
from abc import ABC, abstractmethod
8-
from typing import Any, Callable, Generic, List, Optional, Tuple, TypeVar
8+
from typing import Any, Callable, Generic, Optional, Tuple, TypeVar
99

1010
T = TypeVar("T")
1111

@@ -39,21 +39,21 @@ def set(self, key: str, value: T) -> None:
3939
pass
4040

4141
@abstractmethod
42-
def enumerate_(self) -> List[Tuple[str, Any]]:
42+
def enumerate_(self) -> list[Tuple[str, Any]]:
4343
"""Enumerates all the values stored in the backing store. Values will be filtered if
4444
"ReturnOnlyChangedValues" is true.
4545
4646
Returns:
47-
List[Tuple[str, Any]]: The values available in the backing store.
47+
list[Tuple[str, Any]]: The values available in the backing store.
4848
"""
4949
pass
5050

5151
@abstractmethod
52-
def enumerate_keys_for_values_changed_to_null(self) -> List[str]:
52+
def enumerate_keys_for_values_changed_to_null(self) -> list[str]:
5353
"""Enumerates the keys for all values that changed to null.
5454
5555
Returns:
56-
List[str]: The keys for the values that changed to null.
56+
list[str]: The keys for the values that changed to null.
5757
"""
5858
pass
5959

0 commit comments

Comments
 (0)