Skip to content

Commit 63e157b

Browse files
authored
Merge pull request #433 from microsoft/andrueastman/python38drop
feat: drop support for python 3.8
2 parents 81ff8e8 + 3ef136c commit 63e157b

File tree

70 files changed

+352
-350
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+352
-350
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
max-parallel: 10
2020
matrix:
21-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
21+
python-version: ["3.9", "3.10", "3.11", "3.12"]
2222
library :
2323
- name: "kiota_abstractions"
2424
path: "./packages/abstractions"
@@ -76,7 +76,7 @@ jobs:
7676
strategy:
7777
max-parallel: 10
7878
matrix:
79-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
79+
python-version: ["3.9", "3.10", "3.11", "3.12"]
8080

8181
steps:
8282
- name: Checkout

packages/abstractions/kiota_abstractions/api_client_builder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Callable
1+
from collections.abc import Callable
22

33
from .serialization import (
44
ParseNodeFactory,

packages/abstractions/kiota_abstractions/api_error.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from dataclasses import dataclass
2-
from typing import Dict, Optional
2+
from typing import Optional
33

44

55
@dataclass
@@ -8,7 +8,7 @@ class APIError(Exception):
88

99
message: Optional[str] = None
1010
response_status_code: Optional[int] = None
11-
response_headers: Optional[Dict[str, str]] = None
11+
response_headers: Optional[dict[str, str]] = None
1212

1313
def __str__(self) -> str:
1414
error = getattr(self, "error", None)

packages/abstractions/kiota_abstractions/authentication/access_token_provider.py

Lines changed: 2 additions & 2 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, Dict
8+
from typing import Any
99

1010
from .allowed_hosts_validator import AllowedHostsValidator
1111

@@ -16,7 +16,7 @@ class AccessTokenProvider(ABC):
1616

1717
@abstractmethod
1818
async def get_authorization_token(
19-
self, uri: str, additional_authentication_context: Dict[str, Any] = {}
19+
self, uri: str, additional_authentication_context: dict[str, Any] = {}
2020
) -> str:
2121
"""This method is called by the BaseBearerTokenAuthenticationProvider class to get the
2222
access token.

packages/abstractions/kiota_abstractions/authentication/allowed_hosts_validator.py

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

43

@@ -7,31 +6,31 @@ class AllowedHostsValidator:
76
a host is valid before authenticating a request
87
"""
98

10-
def __init__(self, allowed_hosts: List[str]) -> None:
9+
def __init__(self, allowed_hosts: list[str]) -> None:
1110
"""Creates a new AllowedHostsValidator object with provided values.
1211
1312
Args:
14-
allowed_hosts (List[str]): A list of valid hosts. If the list is empty, all hosts
13+
allowed_hosts (list[str]): A list of valid hosts. If the list is empty, all hosts
1514
are valid.
1615
"""
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

22-
def get_allowed_hosts(self) -> List[str]:
21+
def get_allowed_hosts(self) -> list[str]:
2322
"""Gets the list of valid hosts. If the list is empty, all hosts are valid.
2423
2524
Returns:
26-
List[str]: A list of valid hosts. If the list is empty, all hosts are valid.
25+
list[str]: A list of valid hosts. If the list is empty, all hosts are valid.
2726
"""
2827
return list(self.allowed_hosts)
2928

30-
def set_allowed_hosts(self, allowed_hosts: List[str]) -> None:
29+
def set_allowed_hosts(self, allowed_hosts: list[str]) -> None:
3130
"""Sets the list of valid hosts. If the list is empty, all hosts are valid.
3231
3332
Args:
34-
allowed_hosts (List[str]): A list of valid hosts. If the list is empty, all hosts
33+
allowed_hosts (list[str]): A list of valid hosts. If the list is empty, all hosts
3534
are valid
3635
"""
3736
if not isinstance(allowed_hosts, list):

packages/abstractions/kiota_abstractions/authentication/anonymous_authentication_provider.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

7-
from typing import Any, Dict
7+
from typing import Any
88

99
from ..request_information import RequestInformation
1010
from .authentication_provider import AuthenticationProvider
@@ -20,7 +20,7 @@ class AnonymousAuthenticationProvider(AuthenticationProvider):
2020
async def authenticate_request(
2121
self,
2222
request: RequestInformation,
23-
additional_authentication_context: Dict[str, Any] = {}
23+
additional_authentication_context: dict[str, Any] = {}
2424
) -> None:
2525
"""Authenticates the provided request information
2626

packages/abstractions/kiota_abstractions/authentication/api_key_authentication_provider.py

Lines changed: 3 additions & 3 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, Dict, 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'"
@@ -56,7 +56,7 @@ def __init__(
5656
async def authenticate_request(
5757
self,
5858
request: RequestInformation,
59-
additional_authentication_context: Dict[str, Any] = {}
59+
additional_authentication_context: dict[str, Any] = {}
6060
) -> None:
6161
"""
6262
Ensures that the API key is placed in the correct location for a request.

packages/abstractions/kiota_abstractions/authentication/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 abc import ABC, abstractmethod
8-
from typing import Any, Dict
8+
from typing import Any
99

1010
from ..request_information import RequestInformation
1111

@@ -19,7 +19,7 @@ class AuthenticationProvider(ABC):
1919
async def authenticate_request(
2020
self,
2121
request: RequestInformation,
22-
additional_authentication_context: Dict[str, Any] = {}
22+
additional_authentication_context: dict[str, Any] = {}
2323
) -> None:
2424
"""Authenticates the application request
2525

packages/abstractions/kiota_abstractions/authentication/base_bearer_token_authentication_provider.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

7-
from typing import Any, Dict
7+
from typing import Any
88

99
from ..headers_collection import HeadersCollection
1010
from ..request_information import RequestInformation
@@ -24,7 +24,7 @@ def __init__(self, access_token_provider: AccessTokenProvider) -> None:
2424
async def authenticate_request(
2525
self,
2626
request: RequestInformation,
27-
additional_authentication_context: Dict[str, Any] = {}
27+
additional_authentication_context: dict[str, Any] = {}
2828
) -> None:
2929
"""Authenticates the provided RequestInformation instance using the provided
3030
authorization token

packages/abstractions/kiota_abstractions/base_request_builder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Licensed under the MIT License.
44
# See License in the project root for license information.
55
# ------------------------------------
6-
from typing import Any, Dict, Optional, Union
6+
from typing import Any, Optional, Union
77

88
from .request_adapter import RequestAdapter
99
from .request_information import RequestInformation
@@ -14,7 +14,7 @@ class BaseRequestBuilder:
1414

1515
def __init__(
1616
self, request_adapter: RequestAdapter, url_template: str,
17-
path_parameters: Optional[Union[Dict[str, Any], str]]
17+
path_parameters: Optional[Union[dict[str, Any], str]]
1818
) -> None:
1919
"""Initializes a new instance of the BaseRequestBuilder class."""
2020
if path_parameters is None:
@@ -28,7 +28,7 @@ def __init__(
2828
raise TypeError("url_template cannot be null.") # Empty string is allowed
2929

3030
# Path parameters for the request
31-
self.path_parameters: Dict[str, Any] = path_parameters
31+
self.path_parameters: dict[str, Any] = path_parameters
3232
# Url template to use to build the URL for the current request builder
3333
self.url_template: str = url_template
3434
# The request adapter to use to execute the requests.

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/get_path_parameters.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from typing import Any, Dict, Optional, Union
1+
from typing import Any, Optional, Union
22

33
from .request_information import RequestInformation
44

55

6-
def get_path_parameters(parameters: Union[Dict[str, Any], Optional[str]]) -> Dict[str, Any]:
7-
result: Dict[str, Any] = {}
6+
def get_path_parameters(parameters: Union[dict[str, Any], Optional[str]]) -> dict[str, Any]:
7+
result: dict[str, Any] = {}
88
if isinstance(parameters, str):
99
result[RequestInformation.RAW_URL_KEY] = parameters
1010
elif isinstance(parameters, dict):

packages/abstractions/kiota_abstractions/headers_collection.py

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

3-
from typing import Dict, List, 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:
34-
Dict[str, str]: The headers
34+
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")
@@ -76,20 +76,20 @@ def add_all(self, headers: HeadersCollection) -> None:
7676
"""Adds the specified headers to the collection.
7777
7878
Args:
79-
headers (Dict[str, str]): The headers to add.
79+
headers (dict[str, str]): The headers to add.
8080
"""
8181
if not headers:
8282
raise ValueError("Headers cannot be null")
8383
for key, values in headers.get_all().items():
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,18 +112,18 @@ 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

122122
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:

0 commit comments

Comments
 (0)