Skip to content

Commit fe603f0

Browse files
author
Andrew Omondi
committed
chore: updates deprecated aliases for Callable, Set and FrozenSet
1 parent 6a77a31 commit fe603f0

38 files changed

Lines changed: 91 additions & 71 deletions

packages/abstractions/kiota_abstractions/authentication/allowed_hosts_validator.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from typing import Set
21
from urllib.parse import urlparse
32

43

@@ -17,7 +16,7 @@ def __init__(self, allowed_hosts: list[str]) -> None:
1716
if not isinstance(allowed_hosts, list):
1817
raise TypeError("Allowed hosts must be a list of strings")
1918

20-
self.allowed_hosts: Set[str] = {x.lower() for x in allowed_hosts}
19+
self.allowed_hosts: set[str] = {x.lower() for x in allowed_hosts}
2120

2221
def get_allowed_hosts(self) -> list[str]:
2322
"""Gets the list of valid hosts. If the list is empty, all hosts are valid.

packages/abstractions/kiota_abstractions/headers_collection.py

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

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

55

66
class HeadersCollection():
77
"Represents a collection of request/response headers"
8-
SINGLE_VALUE_HEADERS: Set[str] = {"content-type", "content-encoding", "content-length"}
8+
SINGLE_VALUE_HEADERS: set[str] = {"content-type", "content-encoding", "content-length"}
99

1010
def __init__(self) -> None:
11-
self._headers: dict[str, Set[str]] = {}
11+
self._headers: dict[str, set[str]] = {}
1212

13-
def try_get(self, key: str) -> Union[bool, Set[str]]:
13+
def try_get(self, key: str) -> Union[bool, set[str]]:
1414
"""Gets the header values corresponding to a specific header name.
1515
1616
Args:
1717
key (str): Header key.
1818
1919
Returns:
20-
Union[bool, Set[str]]: The header values for the specified header key or False.
20+
Union[bool, set[str]]: The header values for the specified header key or False.
2121
"""
2222
if not key:
2323
raise ValueError("Header name cannot be null")
@@ -27,22 +27,22 @@ def try_get(self, key: str) -> Union[bool, Set[str]]:
2727
return values
2828
return False
2929

30-
def get_all(self) -> dict[str, Set[str]]:
30+
def get_all(self) -> dict[str, set[str]]:
3131
"""Get all headers and values stored so far.
3232
3333
Returns:
3434
dict[str, str]: The headers
3535
"""
3636
return self._headers
3737

38-
def get(self, header_name: str) -> Set[str]:
38+
def get(self, header_name: str) -> set[str]:
3939
"""Get header values corresponding to a specific header.
4040
4141
Args:
4242
header_name (str): Header key.
4343
4444
Returns:
45-
Set[str]: Values for the header key
45+
set[str]: Values for the header key
4646
"""
4747
if not header_name:
4848
raise ValueError("Header name cannot be null")
@@ -123,7 +123,7 @@ def count(self):
123123
"""Gets the number of headers present in the collection."""
124124
return len(self._headers)
125125

126-
def remove_value(self, header_name: str, header_value: str) -> Union[bool, Set[str]]:
126+
def remove_value(self, header_name: str, header_value: str) -> Union[bool, set[str]]:
127127
"""Removes the specified value from the header with the specified name.
128128
129129
Args:
@@ -147,7 +147,7 @@ def remove_value(self, header_name: str, header_value: str) -> Union[bool, Set[s
147147

148148
return False
149149

150-
def remove(self, header_name: str) -> Union[bool, Set[str]]:
150+
def remove(self, header_name: str) -> Union[bool, set[str]]:
151151
"""Removes the header with the specified name.
152152
153153
Args:

packages/abstractions/kiota_abstractions/multipart_body.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77

88
import io
99
import uuid
10+
from collections.abc import Callable
1011
from dataclasses import dataclass, field
11-
from typing import TYPE_CHECKING, Any, Callable, Generic, Optional, Tuple, TypeVar
12+
from typing import TYPE_CHECKING, Any, Generic, Optional, TypeVar
1213

1314
from .serialization import Parsable
1415

@@ -32,7 +33,7 @@ class MultipartBody(Parsable, Generic[T]):
3233
multipart.serialize(output_file)
3334
"""
3435
boundary: str = str(uuid.uuid4())
35-
parts: dict[str, Tuple[str, Any, Optional[str]]] = field(default_factory=dict)
36+
parts: dict[str, tuple[str, Any, Optional[str]]] = field(default_factory=dict)
3637
request_adapter: Optional[RequestAdapter] = None
3738

3839
def add_or_replace_part(
@@ -59,7 +60,7 @@ def add_or_replace_part(
5960
raise ValueError("Content type cannot be null")
6061
if not part_value:
6162
raise ValueError("Part value cannot be null")
62-
value: Tuple[str, Any, Optional[str]] = (content_type, part_value, filename)
63+
value: tuple[str, Any, Optional[str]] = (content_type, part_value, filename)
6364
self.parts[self._normalize_part_name(part_name)] = value
6465

6566
def get_part_value(self, part_name: str) -> Optional[T]:
@@ -139,7 +140,7 @@ def _add_new_line(self, writer: SerializationWriter) -> None:
139140
writer.write_str_value("", "")
140141

141142
def _get_comtent_disposition(
142-
self, part_name: str, part_value: Tuple[str, Any, Optional[str]]
143+
self, part_name: str, part_value: tuple[str, Any, Optional[str]]
143144
) -> str:
144145
if len(part_value) >= 3 and part_value[2] is not None:
145146
return f'form-data; name="{part_name}"; filename="{part_value[2]}"'

packages/abstractions/kiota_abstractions/request_adapter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from __future__ import annotations
2+
23
from abc import ABC, abstractmethod
34
from datetime import date, datetime, time, timedelta
45
from io import BytesIO

packages/abstractions/kiota_abstractions/request_information.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
# ------------------------------------
66
from __future__ import annotations
77

8+
from collections.abc import Callable
89
from dataclasses import fields, is_dataclass
910
from datetime import date, datetime, time, timedelta, timezone
1011
from enum import Enum
1112
from io import BytesIO
12-
from typing import TYPE_CHECKING, Any, Callable, Optional, TypeVar, Union
13+
from typing import TYPE_CHECKING, Any, Optional, TypeVar, Union
1314
from urllib.parse import unquote
1415
from uuid import UUID
1516

packages/abstractions/kiota_abstractions/serialization/parsable.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from abc import ABC, abstractmethod
2+
from collections.abc import Callable
23
from dataclasses import dataclass
3-
from typing import TYPE_CHECKING, Callable, TypeVar
4+
from typing import TYPE_CHECKING, TypeVar
45

56
T = TypeVar("T")
67

packages/abstractions/kiota_abstractions/serialization/parse_node.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from __future__ import annotations
22

33
from abc import ABC, abstractmethod
4+
from collections.abc import Callable
45
from datetime import date, datetime, time, timedelta
56
from enum import Enum
6-
from typing import TYPE_CHECKING, Callable, Optional, TypeVar
7+
from typing import TYPE_CHECKING, Optional, TypeVar
78
from uuid import UUID
89

910
from .parsable import Parsable

packages/abstractions/kiota_abstractions/serialization/parse_node_helper.py

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

3-
from typing import TYPE_CHECKING, Callable, Optional
3+
from collections.abc import Callable
4+
from typing import TYPE_CHECKING, Optional
45

56
if TYPE_CHECKING:
67
from . import Parsable, ParseNode

packages/abstractions/kiota_abstractions/serialization/parse_node_proxy_factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# See License in the project root for license information.
55
# ------------------------------------------------------------------------------
66

7-
from typing import Callable
7+
from collections.abc import Callable
88

99
from .parsable import Parsable
1010
from .parse_node import ParseNode

packages/abstractions/kiota_abstractions/serialization/serialization_writer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from __future__ import annotations
22

33
from abc import ABC, abstractmethod
4+
from collections.abc import Callable
45
from datetime import date, datetime, time, timedelta
56
from enum import Enum
6-
from typing import Any, Callable, Optional, TypeVar
7+
from typing import Any, Optional, TypeVar
78
from uuid import UUID
89

910
from .parsable import Parsable

0 commit comments

Comments
 (0)