Skip to content

Commit 0ab9092

Browse files
committed
refactor: use @staticmethod instead of @classmethod for field_serializer
@classmethod is not the intended decorator for Pydantic's field_serializer (unlike field_validator which requires it). Using @staticmethod avoids IDE warnings about incorrect descriptor protocol usage.
1 parent 96c7a43 commit 0ab9092

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/mcp/shared/auth.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ class OAuthMetadata(BaseModel):
130130
client_id_metadata_document_supported: bool | None = None
131131

132132
@field_serializer("issuer")
133-
@classmethod
134-
def _serialize_issuer(cls, v: AnyHttpUrl) -> str:
133+
@staticmethod
134+
def _serialize_issuer(v: AnyHttpUrl) -> str:
135135
"""Strip trailing slash added by AnyHttpUrl for RFC 8414 §3.3 compliance."""
136136
return str(v).rstrip("/")
137137

@@ -159,13 +159,13 @@ class ProtectedResourceMetadata(BaseModel):
159159
dpop_bound_access_tokens_required: bool | None = None
160160

161161
@field_serializer("resource")
162-
@classmethod
163-
def _serialize_resource(cls, v: AnyHttpUrl) -> str:
162+
@staticmethod
163+
def _serialize_resource(v: AnyHttpUrl) -> str:
164164
"""Strip trailing slash added by AnyHttpUrl for RFC 9728 §3 compliance."""
165165
return str(v).rstrip("/")
166166

167167
@field_serializer("authorization_servers")
168-
@classmethod
169-
def _serialize_authorization_servers(cls, v: list[AnyHttpUrl]) -> list[str]:
168+
@staticmethod
169+
def _serialize_authorization_servers(v: list[AnyHttpUrl]) -> list[str]:
170170
"""Strip trailing slashes added by AnyHttpUrl for RFC 9728 §3 compliance."""
171171
return [str(s).rstrip("/") for s in v]

0 commit comments

Comments
 (0)