Skip to content

πŸš€ The fast, Pythonic way to build MCP servers and clients.

Use ellipsis default

Jeremiah Lowin23617c9c7263
diff --git a/src/fastmcp/server/auth/providers/bearer_env.py b/src/fastmcp/server/auth/providers/bearer_env.py
index 96cf15cfa..308f5fcd7 100644
--- a/src/fastmcp/server/auth/providers/bearer_env.py
+++ b/src/fastmcp/server/auth/providers/bearer_env.py
@@ -1,13 +1,10 @@
+from types import EllipsisType
+
from pydantic_settings import BaseSettings, SettingsConfigDict
from fastmcp.server.auth.providers.bearer import BearerAuthProvider
-# Sentinel object to indicate that a setting is not set
-class _NotSet:
- pass
-
-
class EnvBearerAuthProviderSettings(BaseSettings):
"""Settings for the BearerAuthProvider."""
@@ -33,11 +30,11 @@ class EnvBearerAuthProvider(BearerAuthProvider):
def __init__(
self,
- public_key: str | None | type[_NotSet] = _NotSet,
- jwks_uri: str | None | type[_NotSet] = _NotSet,
- issuer: str | None | type[_NotSet] = _NotSet,
- audience: str | None | type[_NotSet] = _NotSet,
- required_scopes: list[str] | None | type[_NotSet] = _NotSet,
+ public_key: str | None | EllipsisType = ...,
+ jwks_uri: str | None | EllipsisType = ...,
+ issuer: str | None | EllipsisType = ...,
+ audience: str | None | EllipsisType = ...,
+ required_scopes: list[str] | None | EllipsisType = ...,
):
"""
Initialize the provider.
@@ -57,6 +54,6 @@ class EnvBearerAuthProvider(BearerAuthProvider):
"required_scopes": required_scopes,
}
settings = EnvBearerAuthProviderSettings(
- **{k: v for k, v in kwargs.items() if v is not _NotSet}
+ **{k: v for k, v in kwargs.items() if v is not ...}
)
super().__init__(**settings.model_dump())
diff --git a/tests/utilities/test_types.py b/tests/utilities/test_types.py
index de3c33f77..bb50589f7 100644
--- a/tests/utilities/test_types.py
+++ b/tests/utilities/test_types.py
@@ -1,4 +1,5 @@
import base64
+from types import EllipsisType
from typing import Annotated, Any
import pytest
@@ -308,6 +309,14 @@ class TestFindKwargByType:
assert find_kwarg_by_type(func, SENTINEL) is None # type: ignore
+ def test_ellipsis_annotation(self):
+ """Test finding parameter with an ellipsis annotation."""
+
+ def func(a: int, b: EllipsisType, c: str): # type: ignore # noqa: F821
+ pass
+
+ assert find_kwarg_by_type(func, EllipsisType) == "b" # type: ignore
+
def test_missing_type_annotation(self):
"""Test finding parameter with a missing type annotation."""