Skip to content

Commit 66fb120

Browse files
committed
Use python 3.10 types everywhere
1 parent 6282026 commit 66fb120

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

src/mcp/shared/auth.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, List, Literal, Optional
1+
from typing import Any, Literal
22

33
from pydantic import AnyHttpUrl, BaseModel, Field
44

@@ -10,9 +10,9 @@ class OAuthToken(BaseModel):
1010

1111
access_token: str
1212
token_type: Literal["bearer"] = "bearer"
13-
expires_in: Optional[int] = None
14-
scope: Optional[str] = None
15-
refresh_token: Optional[str] = None
13+
expires_in: int | None = None
14+
scope: str | None = None
15+
refresh_token: str | None = None
1616

1717

1818
class OAuthClientMetadata(BaseModel):
@@ -22,33 +22,33 @@ class OAuthClientMetadata(BaseModel):
2222
for the full specification.
2323
"""
2424

25-
redirect_uris: List[AnyHttpUrl] = Field(..., min_length=1)
25+
redirect_uris: list[AnyHttpUrl] = Field(..., min_length=1)
2626
# token_endpoint_auth_method: this implementation only supports none &
2727
# client_secret_post;
2828
# ie: we do not support client_secret_basic
2929
token_endpoint_auth_method: Literal["none", "client_secret_post"] = (
3030
"client_secret_post"
3131
)
3232
# grant_types: this implementation only supports authorization_code & refresh_token
33-
grant_types: List[Literal["authorization_code", "refresh_token"]] = [
33+
grant_types: list[Literal["authorization_code", "refresh_token"]] = [
3434
"authorization_code"
3535
]
3636
# this implementation only supports code; ie: it does not support implicit grants
37-
response_types: List[Literal["code"]] = ["code"]
38-
scope: Optional[str] = None
37+
response_types: list[Literal["code"]] = ["code"]
38+
scope: str | None = None
3939

4040
# these fields are currently unused, but we support & store them for potential
4141
# future use
42-
client_name: Optional[str] = None
43-
client_uri: Optional[AnyHttpUrl] = None
44-
logo_uri: Optional[AnyHttpUrl] = None
45-
contacts: Optional[List[str]] = None
46-
tos_uri: Optional[AnyHttpUrl] = None
47-
policy_uri: Optional[AnyHttpUrl] = None
48-
jwks_uri: Optional[AnyHttpUrl] = None
49-
jwks: Optional[Any] = None
50-
software_id: Optional[str] = None
51-
software_version: Optional[str] = None
42+
client_name: str | None = None
43+
client_uri: AnyHttpUrl | None = None
44+
logo_uri: AnyHttpUrl | None = None
45+
contacts: list[str] | None = None
46+
tos_uri: AnyHttpUrl | None = None
47+
policy_uri: AnyHttpUrl | None = None
48+
jwks_uri: AnyHttpUrl | None = None
49+
jwks: Any | None = None
50+
software_id: str | None = None
51+
software_version: str | None = None
5252

5353

5454
class OAuthClientInformationFull(OAuthClientMetadata):
@@ -58,9 +58,9 @@ class OAuthClientInformationFull(OAuthClientMetadata):
5858
"""
5959

6060
client_id: str
61-
client_secret: Optional[str] = None
62-
client_id_issued_at: Optional[int] = None
63-
client_secret_expires_at: Optional[int] = None
61+
client_secret: str | None = None
62+
client_id_issued_at: int | None = None
63+
client_secret_expires_at: int | None = None
6464

6565

6666
class OAuthMetadata(BaseModel):

tests/server/fastmcp/auth/test_auth_integration.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import secrets
99
import time
1010
import unittest.mock
11-
from typing import List, Literal, Optional
11+
from typing import Literal
1212
from urllib.parse import parse_qs, urlparse
1313

1414
import anyio
@@ -48,7 +48,7 @@ class MockClientStore:
4848
def __init__(self):
4949
self.clients = {}
5050

51-
async def get_client(self, client_id: str) -> Optional[OAuthClientInformationFull]:
51+
async def get_client(self, client_id: str) -> OAuthClientInformationFull | None:
5252
return self.clients.get(client_id)
5353

5454
async def register_client(self, client_info: OAuthClientInformationFull):
@@ -145,7 +145,7 @@ async def exchange_refresh_token(
145145
self,
146146
client: OAuthClientInformationFull,
147147
refresh_token: RefreshToken,
148-
scopes: List[str],
148+
scopes: list[str],
149149
) -> OAuthToken:
150150
# Check if refresh token exists
151151
assert refresh_token.token in self.refresh_tokens

0 commit comments

Comments
 (0)